shadcn.io is not affiliated with official shadcn/ui
The baseline for any form: a Textarea with a visible label. The Field stacks a FieldLabel over the Textarea and ties the two together, so the label names the field for screen readers and a click on it focuses the field.
Preview
Installation
FAQ
How does the FieldLabel link to the Textarea?
The label's for attribute points at the Textarea's id, which gives the field its accessible name and makes clicking the label focus it.
Give the Textarea an id and point the FieldLabel at it with htmlFor, as the demo does.
Should the label go above or beside the textarea?
Above, as here, for most forms: a textarea is tall, and a label above reads naturally and fits any width. Put it beside only in dense settings layouts, as the Textarea with Inline Label example does.
What spacing should I use between label and textarea?
The Field sets it, the same gap as every other field, so forms stay consistent. Change it with a gap-* class on the Field if your form needs more or less.
How do I indicate a required textarea field?
Set required so the browser and screen readers know, and add an asterisk to the label for sighted users. The Required Textarea example shows both.
Related
- Textarea with DescriptionA textarea with a description between its
- Textarea with Helper TextA textarea with helper text under it that
- Textarea with Floating LabelA textarea whose label sits inside it
- Textarea with Inline LabelA three-row textarea with its label
- Input with LabelA text input with a label above it
- Required TextareaA required textarea with a red asterisk