Skip to content
shadcn.io

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.

Framework
UI library

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

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

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.

Why use min-h-0 on the inline textarea?

The Textarea normally grows with its content from min-h-16. field-sizing-fixed makes it honor rows, and min-h-0 lets it be shorter than the minimum, so it stays three lines tall and the row keeps its alignment.

How many rows should inline textareas have?

Three to five. Fewer, and an Input is the better control; more, and the label floats beside a tall box, so stack the label above instead.