shadcn.io is not affiliated with official shadcn/ui
Textarea examples · Form
Textarea with Hint for React
A textarea with an Optional hint at the end of its label row.
When most of a form is required, mark the exceptions. Here the label row puts the FieldLabel at the start and a muted Optional at the end with justify-between, so people know they can skip the field before they reach it.
Preview
Installation
FAQ
Should I mark optional fields or required fields?
Mark whichever is rarer. A sign-up form is mostly required, so mark its optional fields as here; a profile form is mostly optional, so mark its required ones with an asterisk, as the Required Textarea example does.
Why place Optional on the right side of the label?
The row is flex with justify-between, which puts the hint at the end edge, apart from the label, where it's easy to find but doesn't interrupt it. The end edge is the left in a right-to-left layout. Optional in parentheses after the label works too.
What styling should I use for the optional hint?
text-muted-foreground and text-sm, as here, so it reads as secondary to the label without disappearing.
Can I use different wording instead of Optional?
Yes. Optional is the most widely understood, but a short phrase that fits your form's tone works. Use the same word on every optional field.
Related
- Required TextareaA required textarea with a red asterisk
- Textarea with Helper TextA textarea with helper text under it that
- Label with Optional IndicatorA label with a muted (optional) marker
- Optional Field InputA field whose label marks it as optional
- Textarea with Character CountA textarea with a live count of its
- Textarea with ErrorAn invalid textarea with a destructive