Skip to content
shadcn.io

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.

Framework
UI library

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

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

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.

What if I have equal required and optional fields?

Mark the required ones, since leaving one empty blocks submitting, or say at the top that every field is required unless marked optional. Don't mark both.

Does the Optional hint layout work on mobile?

Yes. The label and the hint stay on one line at any usual width, and the hint keeps to the end edge as the form narrows.