Skip to content

Select

Displays a list of options and allows a single value to be selected.
<Select>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel />
<SelectItem />
</SelectGroup>
<SelectSeparator />
</SelectContent>
</Select>

To create a select menu, compose <Select>, <SelectTrigger>, <SelectValue>, <SelectContent>, and one or more <SelectItem> components.

import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
} from "stylus-ui/Select";
export default () => (
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select a fruit" />
</SelectTrigger>
<SelectContent>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
<SelectItem value="orange">Orange</SelectItem>
<SelectItem value="grape">Grape</SelectItem>
</SelectContent>
</Select>
);

Use <SelectGroup> and <SelectLabel> to organize items into labeled groups.

import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectGroup,
SelectLabel,
SelectItem,
SelectSeparator,
} from "stylus-ui/Select";
export default () => (
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Select a food" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Fruits</SelectLabel>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
</SelectGroup>
<SelectSeparator />
<SelectGroup>
<SelectLabel>Vegetables</SelectLabel>
<SelectItem value="carrot">Carrot</SelectItem>
<SelectItem value="celery">Celery</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
);

The root component that contains all the select parts.

Prop
Type
Default
defaultOpen boolean
defaultValue string
disabled boolean
name string
onOpenChange (open: boolean) => void
onValueChange (value: string) => void
open boolean
value string

The button that toggles the select.

Prop
Type
Default
children ReactNode
className string
showDirectionArrow boolean true

The selected value to display in the trigger.

Prop
Type
Default
placeholder string

The floating content that contains the select items.

Prop
Type
Default
className string
position string "popper"

A selectable item.

Prop
Type
Default
value string
className string
disabled boolean

Used to group multiple items together.

Prop
Type
Default
children ReactNode

Used to render a label for a group of items.

Prop
Type
Default
children ReactNode
className string

Used to visually separate items in the select.

Prop
Type
Default
className string