Select

Displays a list of options for the user to pick from, triggered by a button.

Installation

pnpm dlx cubix@latest add select --base radix

Usage

Import
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from "@/components/cubix/select"
Example
<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

PropTypeDefaultDescription
valuestring-Controlled selected value. Use with `onValueChange`.
defaultValuestring-Default selected value for uncontrolled usage.
disabledbooleanfalseDisables the select and prevents interaction.
namestring-Name submitted with the parent form.
childrenReact.ReactNode-SelectTrigger, SelectContent, and SelectItem parts of the control.