shadcn.io is not affiliated with official shadcn/ui
Input Group examples · Custom
Textarea with Label Input Group for React
A comment textarea with its label in a header row and a Post Comment button under it.
A comment box whose label lives inside the frame: a block-start addon with a bottom border holds the Comment label, the textarea follows, and a block-end addon holds the Post Comment button. The label points at the textarea with htmlFor and id, so clicking it focuses the field.
Preview
Installation
FAQ
How does the label sit inside the box?
It's in an InputGroupAddon with align="block-start" and border-b, written after the textarea. Block start puts the addon above it as a header row.
How is the label tied to the textarea?
Label has htmlFor set to the textarea's id. Outside a Field, that pair is what names the control and makes the label clickable.
Why does the label use text-foreground?
Addons use the muted text color; text-foreground keeps the label at full contrast, as a label should be.
Where is the Post Comment button?
In a second addon with align="block-end", under the textarea, pushed to the end by ms-auto.
Related
- Textarea with Actions Input GroupA message textarea with a Submit button
- Textarea with Counter Input GroupA message textarea with a 500-character
- Textarea with Toolbar Input GroupA textarea with bold, italic and
- Input with LabelA text input with a label above it
- Input with DescriptionA field with a description between its
- Two Field FormA two-field contact form for a name and