Select
Select lets users choose one value from a dropdown.
import { Select } from '@/components/ui/wideset/select/Select';
<Select
options={[
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
{ value: 'marketing', label: 'Marketing' },
{ value: 'support', label: 'Customer support' },
]}
defaultValue="engineering"
placeholder="Choose a team"
aria-label="Team"
/>Installation
pnpm dlx wideset add select
Copies the component and any Wideset components it uses into your project.
Examples
Variants
Primary is the default. Danger marks a choice that failed validation, such as a required field left empty on submit; put the reason in the FormField's errorText, which the field links to the control with aria-describedby, because the red border alone does not reach screen reader users.
import { Select } from '@/components/ui/wideset/select/Select';
const TEAMS = [
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
{ value: 'marketing', label: 'Marketing' },
];
export default function SelectVariants() {
return (
<div className="gap-ws-12 flex w-[16rem] max-w-full flex-col">
{(['primary', 'danger'] as const).map((variant) => (
<Select
key={variant}
variant={variant}
options={TEAMS}
placeholder="Choose a team"
aria-label="Team"
/>
))}
</div>
);
}Presets
Border is the default, for a select in a form or on the page. Ghost drops the frame and reads as a value: its arrow and a soft background show on hover, keyboard focus or while open. Use it for a select inside a surface that already has one, such as a toolbar, a card header or a table cell.
import { Select } from '@/components/ui/wideset/select/Select';
const TEAMS = [
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
{ value: 'marketing', label: 'Marketing' },
];
export default function SelectPresets() {
return (
<div className="gap-ws-12 flex w-[16rem] max-w-full flex-col">
{(['border', 'ghost'] as const).map((preset) => (
<Select
key={preset}
preset={preset}
options={TEAMS}
defaultValue="engineering"
aria-label="Team"
/>
))}
</div>
);
}Sizes
Medium is the default for forms. Small fits filter bars and dense tables, large a short form that is the main task on the page. Match the size of the fields and buttons next to the select.
import { Select } from '@/components/ui/wideset/select/Select';
const TEAMS = [
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
{ value: 'marketing', label: 'Marketing' },
];
export default function SelectSizes() {
return (
<div className="gap-ws-12 flex w-[16rem] max-w-full flex-col">
{(['sm', 'md', 'lg'] as const).map((size) => (
<Select
key={size}
size={size}
options={TEAMS}
placeholder="Choose a team"
aria-label="Team"
/>
))}
</div>
);
}States
The placeholder shows until a value is chosen; with clearable a clear button appears once one is, and it empties the value without opening the list. A disabled select is skipped by Tab and shows no clear button.
import { Select } from '@/components/ui/wideset/select/Select';
const TEAMS = [
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
{ value: 'marketing', label: 'Marketing' },
];
export default function SelectStates() {
return (
<div className="gap-x-ws-7 gap-y-ws-5 grid grid-cols-[6rem_16rem] items-center">
<span className="typography-caption-md text-ws-static-subtle">Placeholder</span>
<Select options={TEAMS} placeholder="Choose a team" aria-label="Team" />
<span className="typography-caption-md text-ws-static-subtle">Chosen</span>
<Select options={TEAMS} defaultValue="engineering" aria-label="Team" clearable />
<span className="typography-caption-md text-ws-static-subtle">Disabled</span>
<Select options={TEAMS} defaultValue="engineering" aria-label="Team" disabled />
</div>
);
}API reference
Select
| Name | Description | Default |
|---|---|---|
children | Sub-components for composable usage (`Select.Trigger`, `Select.Content`, `Select.Option`, etc.). Use instead of `options` when you need grouped options, custom layouts, or full rendering control. ReactNode | — |
className | Additional CSS classes applied to the trigger element. Width utilities (e.g. `w-[20rem]`) override the default width. string | — |
clearable | Whether to show a clear button in the trigger when a value is selected. boolean | — |
clearSelectionAriaLabel | Accessible label for the clear-selection button. Defaults to `'Clear selection'`. string | 'Clear selection' |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
hasSearch | Whether to show a search input at the top of the dropdown that filters options by label. boolean | false |
hideArrow | Whether to hide the dropdown arrow icon on the right side of the trigger. boolean | — |
id | HTML `id` attribute for the trigger element, useful for form label association. string | — |
name | HTML `name` attribute forwarded for form submission. string | — |
onClear | Called when the clear button is clicked. Use for custom reset logic beyond clearing the value. (() => void) | — |
options | Array of options to display in the dropdown. Each item requires `value` and `label`. SelectOptionType<Record<string, unknown>>[] | — |
placeholder | Placeholder text shown in the trigger when no option is selected. string | — |
preset | Visual style preset. `border` adds a visible border and background; `ghost` uses a transparent background. 'border''ghost' | — |
size | Controls the height, padding, and typography size of the trigger. 'sm''md''lg' | — |
variant | Color variant. `danger` applies error styling for form validation feedback. 'primary''danger' | 'primary' |
<button> is passed through to it. See MDN: <button>.Select.Content
| Name | Description | Default |
|---|---|---|
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
portalContainer | DOM node to portal the dropdown content into. Defaults to `document.body`. Element | DocumentFragment | — |
position | Controls how the dropdown is positioned relative to the trigger. 'item-aligned''popper' | 'popper' |
shouldUsePrimitive | Internal flag — set to `false` to render as a `DropdownMenu.Content` instead of the Radix Select portal (used inside Dropdown). boolean | true |
Radix Select.Content is passed through to it. See Radix Select.Content.Select.Group
Radix Select.Group is passed through to it. See Radix Select.Group.Select.ItemIndicator
Radix Select.ItemIndicator is passed through to it. See Radix Select.ItemIndicator.Select.ItemText
Radix Select.ItemText is passed through to it. See Radix Select.ItemText.Select.Label
Radix Select.Label is passed through to it. See Radix Select.Label.Select.Option
| Name | Description | Default |
|---|---|---|
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
disabled | Disables interaction with the control. boolean | — |
shouldDisplayCheckmark | Whether to show a checkmark indicator on the selected option. boolean | true |
shouldUsePrimitive | Internal flag — omit or set to `true` to use the Radix Select item primitive. Internal flag — set to `false` to render as a plain `<div>` (used inside Dropdown). boolean | true |
textValue | string | — |
value | string | — |
variant | Color variant applied to the option row. `danger` renders red text for destructive choices. 'primary''danger' | — |
Select.Root
Radix Select.Root is passed through to it. See Radix Select.Root.Select.ScrollDownButton
Radix Select.ScrollDownButton is passed through to it. See Radix Select.ScrollDownButton.Select.ScrollUpButton
Radix Select.ScrollUpButton is passed through to it. See Radix Select.ScrollUpButton.Select.Search
| Name | Description | Default |
|---|---|---|
className | Additional CSS classes applied to the search wrapper. string | — |
onChange | Called when the search input value changes. ChangeEventHandler<HTMLInputElement, Element> | — |
onClear | Called when the clear button inside the search input is clicked. (() => void) | — |
value | Current search query value for controlled usage. string | — |
<input> is passed through to it. See MDN: <input>.Select.Separator
Radix Select.Separator is passed through to it. See Radix Select.Separator.Select.Trigger
| Name | Description | Default |
|---|---|---|
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
hideArrow | Whether to hide the dropdown arrow icon on the right side of the trigger. boolean | — |
id | HTML `id` attribute forwarded to the trigger element for form label association. string | — |
name | HTML `name` attribute forwarded for form submission. string | — |
placeholder | Placeholder text shown when no value is selected. Also used as the accessible label fallback. string | — |
preset | Visual style preset. `border` adds a visible border and background; `ghost` uses a transparent background. 'border''ghost' | 'border' |
shouldUsePrimitive | Internal flag — set to `false` to render a plain `<button>` instead of the Radix Select trigger (used inside Dropdown). boolean | true |
size | Controls the height, padding, and typography size of the trigger. 'sm''md''lg' | 'md' |
variant | Color variant. `danger` applies error styling for form validation feedback. 'primary''danger' | 'primary' |
Radix Select.Trigger is passed through to it. See Radix Select.Trigger.Select.Value
Radix Select.Value is passed through to it. See Radix Select.Value.Accessibility
- Name it:
FormFieldhtmlFor+idon Select (it lands on the trigger), oraria-label. - Radix gives the listbox roles, typeahead and arrow keys.
- The clear button is labelled “Clear selection”; translate with
clearSelectionAriaLabel.
| Part | Renders | Description |
|---|---|---|
| SelectRenders no element | <button> | A dropdown selection control for one value. |
| Select.ContentRenders no element | Radix Select.Content | The content surface rendered within `Select`. |
| Select.GroupRenders no element | Radix Select.Group | The Radix Select group. |
| Select.ItemIndicatorOnly when open | Radix Select.ItemIndicator | Props for `Select.ItemIndicator`. |
| Select.ItemTextOnly when open | Radix Select.ItemText | Props for `Select.ItemText`. |
| Select.LabelRenders no element | Radix Select.Label | The text label associated with `Select`. |
| Select.OptionRenders no element | — | A selectable option within the dropdown. |
| Select.RootRenders no element | Radix Select.Root | Props for the Radix Select root, which holds open and value state and renders no DOM. |
| Select.ScrollDownButtonOnly when open | Radix Select.ScrollDownButton | Button that scrolls the option list down when it overflows. |
| Select.ScrollUpButtonOnly when open | Radix Select.ScrollUpButton | Button that scrolls the option list up when it overflows. |
| Select.SearchRenders no element | <input> | Search input inside the dropdown for filtering options. |
| Select.SeparatorRenders no element | Radix Select.Separator | A visual separator between groups of items. |
| Select.TriggerRenders no element | Radix Select.Trigger | The control that opens or toggles the associated content. |
| Select.ValueRenders no element | Radix Select.Value | Renders the selected value inside the trigger. |
import { Select } from '@/components/ui/wideset/select/Select';
<Select
options={[
{ value: 'design', label: 'Design' },
{ value: 'engineering', label: 'Engineering' },
{ value: 'marketing', label: 'Marketing' },
{ value: 'support', label: 'Customer support' },
]}
defaultValue="engineering"
placeholder="Choose a team"
aria-label="Team"
/>