Forms & Inputs
@hacline/ui/textareaTextarea
Enter multi-line text with optional automatic height adjustment.
Usage
Type or add line breaks to update the character count feedback. Pair Textarea with FieldLabel and set autoResize to expand the input area with its content.
"use client";
import { useState } from "react";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
import { Textarea } from "@/components/ui/hacline/components/textarea";
const MAX_LENGTH = 120;
export const Example = () => {
const [notes, setNotes] = useState("");
const isTooShort = notes.length > 0 && notes.length < 10;
return (
<div className="flex w-full max-w-sm flex-col gap-4">
<Field invalid={isTooShort} name="review-notes">
<FieldLabel>Review notes</FieldLabel>
<Textarea
aria-invalid={isTooShort || undefined}
autoResize
maxLength={MAX_LENGTH}
onValueChange={setNotes}
placeholder="Add items to confirm in the next review"
rows={3}
value={notes}
/>
<output
aria-label="Character count"
className="text-hl-fg-muted text-end text-xs"
>
{notes.length} / {MAX_LENGTH}
</output>
</Field>
<Field disabled name="archived-notes">
<FieldLabel>Archived summary (disabled)</FieldLabel>
<Textarea
defaultValue="Locked after release sign-off."
disabled
rows={2}
variant="filled"
/>
</Field>
</div>
);
};Submit Form with a Shortcut
Pressing Enter inserts a line break as usual, while Ctrl or Command + Enter submits the form and still runs required field validation.
"use client";
import { useState } from "react";
import { Button } from "@/components/ui/hacline/components/button";
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/hacline/components/field";
import { Textarea } from "@/components/ui/hacline/components/textarea";
export const Example = () => {
const [message, setMessage] = useState("");
return (
<form
action={(data) => setMessage(String(data.get("reply")))}
className="grid w-full max-w-sm justify-items-start gap-2"
>
<Field className="w-full" name="reply">
<FieldLabel>Sample reply</FieldLabel>
<Textarea required rows={2} submitShortcut="mod+enter" />
<FieldDescription>Press Ctrl / ⌘ + Enter to submit.</FieldDescription>
</Field>
<Button size="sm" type="submit" variant="outline">
Submit reply
</Button>
{message && (
<output className="text-hl-fg-muted text-xs">
Submitted: {message}
</output>
)}
</form>
);
};Props
Prop
Type