Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Advanced

Complex Multi-Field Form for React

A personal information fieldset with name, email and country fields.

Framework
UI library

A form section that mixes control types and widths: First Name and Last Name share a two-column row, then Email and a Country Select take the full width. A FieldSet with a FieldLegend captions the group and a FieldGroup spaces the fields. Use it for sign-up, checkout and profile forms.

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 Personal Information line?

FieldLegend on FieldSet is the caption, in the default legend style. FieldGroup stacks the rows under it. There is no FieldDescription on the set.

How do First Name and Last Name share a row?

They sit in a grid with grid-cols-2 and gap-4. Both inputs use type text, with placeholders John and Doe.

How is Email different from the name row?

Email is its own full-width Field under the grid. type is email, and the placeholder is john@example.com.

What does the country select show before a choice?

The trigger shows the placeholder Select country. It's the placeholder on SelectValue. The items are United States, United Kingdom, and Canada, each a SelectItem.

How does each label connect?

FieldLabel names the control. Its htmlFor matches the control's id.For Country, that id is on the SelectTrigger. The labels are First Name, Last Name, Email, and Country.

How wide is the set?

The set is capped with max-w-md. Email and Country each take the full width under the name row.