Select
Displays a list of options for the user to pick from, triggered by a button.
Installation
pnpm dlx cubix@latest add select --base radixUsage
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/cubix/select"<Select defaultValue="apple">
<SelectTrigger className="w-full max-w-sm">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="apple">Apple</SelectItem>
<SelectItem value="banana">Banana</SelectItem>
<SelectItem value="blueberry">Blueberry</SelectItem>
</SelectContent>
</Select>Examples
With label and helper text
Choose the framework for your project.
Invalid state
Set aria-invalid to switch to destructive border and ring styles.
Disabled
In a form
API Reference
Note: The select is a composed control. Put items in SelectContent and size the trigger with className.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled selected value. Use with `onValueChange`. |
| defaultValue | string | - | Default selected value for uncontrolled usage. |
| disabled | boolean | false | Disables the select and prevents interaction. |
| name | string | - | Name submitted with the parent form. |
| children | React.ReactNode | - | SelectTrigger, SelectContent, and SelectItem parts of the control. |