shadcn.io is not affiliated with official shadcn/ui
Field examples · Selects
Select in Horizontal Layout Field for React
A theme select with its label beside it in a horizontal field.
Framework
UI library
A settings row: the Theme label on one side, a Select of Light, Dark and System on the other, opening on System. orientation="horizontal" on the Field keeps them on one line.
Preview
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 the label and the select share a row?
orientation is horizontal on Field, so Theme and the Select sit side by side. max-w-md caps the row.
Which theme is selected at first?
There is no placeholder, because a theme is already selected. The items are Light, Dark, and System.
Set defaultValue to system.
Where do Light, Dark, and System go?
Each theme is a SelectItem. The trigger shows the selected label.
How does the Theme label connect?
FieldLabel names the select. Its htmlFor matches the SelectTrigger's id. The label is the first child of the horizontal field.
Related
- Simple Select FieldA country select with a label and a
- Horizontal Layout FieldAn input and a select, each with its
- Select with Default Value FieldAn account status select that opens on
- Theme Selector Dropdown MenuA theme picker behind a palette button
- Responsive Layout FieldTwo fields that stack in a narrow
- Default SwitchA switch in its default off state, with