Overview
The Dropdown component is built from composable pieces:Dropdown.Rootmanages open state, selection, and keyboard interaction.Dropdown.Selectrenders the trigger button with label, helper text, and icons.Dropdown.PopoverandDropdown.Menudisplay the list of options with proper focus management.Dropdown.Sectiongroups options and can render checkbox-style multi selection.Dropdown.Itemregisters an option and handles selection feedback.
Basic Usage
- Code
- Preview
Single Selection
- Code
- Preview
Multiple Selection
UseDropdown.Root with multiple and render a Dropdown.Section with variant="checkbox" to display checkbox affordances. The trigger automatically shows the number of selected items, so render a summary elsewhere if you need labels.
- Code
- Preview
With Groups
Render multipleDropdown.Section blocks to visually separate categories. Add custom headings within a section as needed.
- Code
- Preview
Props
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
| Root | value | string | number | (string | number)[] | null | — | Controlled selected value(s); pass an array when multiple is set |
| Root | defaultValue | string | number | (string | number)[] | null | — | Uncontrolled initial value(s) |
| Root | onChange | (value: string | number | null) => void || (values: (string | number)[]) => void | — | Fired when the selection changes; signature depends on multiple |
| Root | multiple | boolean | false | Enables multiple selection mode |
| Root | className | string | — | Applies custom classes to the wrapper |
| Select | label | React.ReactNode | — | Optional field label rendered above the trigger |
| Select | required | boolean | false | Shows an asterisk next to the label |
| Select | placeholder | string | "Select" | Placeholder text when nothing is selected |
| Select | startIcon | React.ReactNode | — | Icon displayed on the left of the trigger |
| Select | helperText | React.ReactNode | — | Helper text shown below the trigger |
| Select | errorMessage | React.ReactNode | — | Error text shown below the trigger with error styling |
| Select | className | string | — | Additional classes for the trigger button |
| Popover | className | string | — | Styles for the popover container |
| Popover | children | React.ReactNode | — | Popover contents, usually a Dropdown.Menu |
| Menu | className | string | — | Styles for the menu surface |
| Menu | maxHeight | number | 320 | Sets the max height before the menu scrolls |
| Menu | children | React.ReactNode | — | Menu sections and other content |
| Section | className | string | — | Adds spacing or borders around a section |
| Section | variant | "default" | "checkbox" | "default" | Renders checkbox visuals when set to "checkbox" |
| Section | children | React.ReactNode | — | Section content such as Dropdown.Item elements |
| Item | value | string | number | — | Value emitted on selection; defaults to the text content |
| Item | disabled | boolean | false | Disables the option |
| Item | startIcon | React.ReactNode | — | Optional leading icon when variant="default" |
| Item | className | string | — | Custom classes for the option |
| Item | children | React.ReactNode | — | Option label/content |
Examples
Multi-Select with Custom Display
- Code
- Preview