Select
Displays a list of options and allows a single value to be selected.
Anatomy
Section titled “Anatomy”<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>);With groups
Section titled “With groups”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>);API Reference
Section titled “API Reference”Select
Section titled “Select”The root component that contains all the select parts.
SelectTrigger
Section titled “SelectTrigger”The button that toggles the select.
SelectValue
Section titled “SelectValue”The selected value to display in the trigger.
SelectContent
Section titled “SelectContent”The floating content that contains the select items.
SelectItem
Section titled “SelectItem”A selectable item.
SelectGroup
Section titled “SelectGroup”Used to group multiple items together.
SelectLabel
Section titled “SelectLabel”Used to render a label for a group of items.
SelectSeparator
Section titled “SelectSeparator”Used to visually separate items in the select.