A select displays a collapsible list of options and allows a user to select one of them or multiple of them.
variant
selectionMode
size
isDisabled
1<Select
2 className="w-40"
3 placeholder="Choose an option..."
4>
5 <Select.Item>
6 Option 1
7 </Select.Item>
8 <Select.Item>
9 Option 2
10 </Select.Item>
11 <Select.Item>
12 Option 3
13 </Select.Item>
14</Select>1<Select>
2 <Select.Item></Select.Item>
3</Select>npm install @rootui/select1import { Select } from "@rootui/select";
2
3export default function Page() {
4 return (
5 <Select>
6 <Select.Item>my first item</Select.Item>
7 <Select.Item>my second item</Select.Item>
8 </Select>
9 )
10}See the React Aria documentation for more information.
Prop | Type | Default |
|---|---|---|
| | |
| | |
| | |
Temporary text that occupies the select when it is empty. | ||
| | |
Whether the select should be allowed to be open when the collection is empty. | ||
| | |
Whether the input is disabled. | ||
| | |
Whether single or multiple selection is enabled. | ||
| | |
The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. | ||
| | |
The current value (controlled). | ||
| | |
The default value (uncontrolled). | ||
| | |
Handler that is called when the value changes. | ||
| | |
Sets the open state of the menu. | ||
| | |
Sets the default open state of the menu. | ||
| | |
Method that is called when the open state of the menu changes. | ||
Attribute | Description |
|---|---|
| Whether the select is focused, either via a mouse or keyboard. |
| Whether the select is keyboard focused. |
| Whether the select is disabled. |
| Whether the select is currently open. |
| Whether the select is invalid. |
| Whether the select is required. |
Prop | Type | Default |
|---|---|---|
| | |
The children of the component. A function may be provided to alter the children based on component state. | ||