Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Layouts

Nested Fields for React

A shipping address fieldset with a nested group and a two-column row.

Framework
UI library

An address form with a hierarchy: Street Address with an apartment line nested under it, then City and ZIP Code side by side. A FieldSet with a FieldLegend and a FieldDescription holds it all, and a nested FieldGroup keeps the secondary line close to the street field.

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 Shipping Address line?

FieldLegend on FieldSet is the caption, in the default legend style. FieldDescription under it reads Where should we send your order?

How is the street field different from the apartment field?

Street Address is a Field in the outer FieldGroup. Apartment, suite, etc. sits in a second FieldGroup nested under that street field.

How do City and ZIP Code share a row?

They sit in a grid with grid-cols-2 and gap-4, still inside the outer FieldGroup. Placeholders are New York and 10001.

What do the inputs accept?

Every Input uses type text. Street's placeholder is 123 Main St, and the apartment placeholder is Apt 4B.

How does each label connect?

FieldLabel names the input. Its htmlFor matches the control's id. The set's legend does not replace those labels.

How wide is the address?

The set is capped with max-w-md. The nested group is another column inside that width.