Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Advanced

Fieldset with Legend for React

An address fieldset with a legend, a description and three inputs.

Framework
UI library

Group related inputs under one caption. A FieldSet with a FieldLegend (Address Information) and a FieldDescription holds Street Address on its own row, then City and Postal Code side by side. The fieldset and legend give the group its name for screen readers as well as on screen.

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

What is the Address Information line?

FieldLegend on FieldSet is the caption. variant is left unset, so it uses the default legend style. The legend is announced with each field's own label.

Where is the delivery sentence?

FieldDescription sits under the legend, on the set: We need your address to deliver your order. The inputs have their own labels under that.

How is the street field laid out?

Street Address is a full-width Field in the FieldGroup. type is text, and the placeholder is 123 Main St.

How do City and Postal Code share a row?

They sit in a grid with grid-cols-2 and gap-4. Placeholders are New York and 90502, and both inputs use type text.

How does each label connect?

FieldLabel names the input. Its htmlFor matches the control's id. The labels are Street Address, City, and Postal Code.

How wide is the address set?

The set is capped with max-w-md. The legend, the description, and the fields share that width.