Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Layouts

Grid Layout Field for React

Personal details in a grid: two equal columns, then a wide city field beside a narrow state field.

Framework
UI library

Put fields that belong together on one row and size each to its content. Inside a FieldSet, a two-column grid pairs First Name and Last Name, and a three-column grid gives City two columns and State one. Each cell is an ordinary Field, so labels and spacing stay consistent.

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 are First Name and Last Name placed on one row?

They sit in a grid with grid-cols-2 and gap-4. Each cell is its own Field with a FieldLabel and an Input.

How does City take more room than State?

That row is a grid with grid-cols-3 and gap-4. City's Field has col-span-2, so State keeps the last column.

What is the Personal Details line?

FieldLegend with variant set to label is the caption on the FieldSet. label is the quieter legend. This set has no FieldDescription.

What do the inputs accept?

Every Input uses type text. The placeholders are John, Doe, New York, and NY.

How does each label connect?

FieldLabel names the input. Its htmlFor matches the control's id. The labels are First Name, Last Name, City, and State.

How wide is the set?

The set is capped with max-w-md. FieldGroup stacks the two grid rows under the legend.