shadcn.io is not affiliated with official shadcn/ui
Textarea examples · Labeled
Textarea with Inline Label for React
A three-row textarea with its label beside it instead of above.
Where width is plentiful and height isn't, put the label beside the field. Field with orientation set to horizontal lays out the FieldLabel and the Textarea in a row, centered, and the Textarea is held at three rows with field-sizing-fixed, min-h-0 and rows.
Preview
Installation
FAQ
How do I align the label with a multi-line textarea?
The horizontal Field centers its children, which suits a three-row Textarea. For a taller one, add items-start to the Field so the label lines up with the first line of text.
Why use fixed width w-20 for the inline label?
w-20 gives the label the same width on every row, so a stack of inline fields starts its controls at one edge. Widen it to fit your longest label.
What gap spacing works best for inline label layouts?
The Field's own gap, as here, keeps the label and field visibly apart but paired. Change it with a gap-* class on the Field and use the same value on every row.
When should I use inline labels instead of labels above?
In settings panels and admin forms with many short fields, where rows scan faster than stacks. On narrow screens and for long labels, put the label above; orientation set to responsive switches between the two with the container's width.
Related
- Textarea with LabelA textarea with a visible label above it
- Short TextareaA compact textarea fixed at three rows
- Horizontal Layout FieldAn input and a select, each with its
- Inline Label InputA field with its label beside the input
- Textarea with DescriptionA textarea with a description between its
- Textarea with Floating LabelA textarea whose label sits inside it