Textarea
Several lines of free text, such as a note or a description.
When to use
- Free text that can run past one line: a note, a description, a message to a clinician.
When not to use
- One line, such as a name or a URL: use Input.
- Text with a button or a hint attached inside the border, such as a prompt box: use Input Group with
InputGroupTextarea.
Install
npx shadcn@latest add @clinia/textareaMarketing (Sera)
Clinia rules
- The border is the
inputtoken, like Input, so the field edge clears 3:1 on the page and on cards. - The box grows with its content (
field-sizing-content) from a 64px minimum, and it can't be resized by hand. Set amin-h-*class to show how much text you expect:rowshas no effect underfield-sizing-content. - Text is 16px on small screens and 14px from
mdup, so iOS doesn't zoom in on focus.
Do and don't
States: product (Luma)
placeholder
filled
focus
invalid
disabled
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
States: marketing (Sera)
placeholder
filled
focus
invalid
disabled
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
Accessibility
Built in
- Focus-visible shows a solid Trust ring (
border-ring ring-3 ring-ring/30);aria-invalidswaps it to a destructive ring.
Your responsibility
- Give it a visible label:
FieldLabelinsideField, orLabelwithhtmlFor. - If there is a length limit, say so in a
FieldDescriptionand pointaria-describedbyat it. Don't rely onmaxLengthalone: it cuts text off silently. - On error, set
aria-invalidand pointaria-describedbyat theFieldError.
How to test
- Click the label: focus moves to the textarea.
- Press Tab into it: the Trust ring appears. Type several lines: the box grows and nothing is clipped.
- Press Enter: it adds a new line and doesn't submit the form.
- With a screen reader, it's announced as its label, then as an edit text with multiple lines.
API
Every prop comes from the native textarea element.
Related