Select
FormDropdown select menu built on Radix UI Select primitive.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
SelectGroup,
SelectLabel,
} from "@dashboardpack/core/components/ui/select";
import { useState } from "react";
export default function SelectExample() {
const [role, setRole] = useState("editor");
return (
<div className="w-full max-w-xs space-y-4">
<Select value={role} onValueChange={setRole}>
<SelectTrigger aria-label="Team role">
<SelectValue placeholder="Choose a role" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel>Team roles</SelectLabel>
<SelectItem value="viewer">Viewer</SelectItem>
<SelectItem value="editor">Editor</SelectItem>
<SelectItem value="admin">Admin</SelectItem>
<SelectItem value="owner" disabled>
Owner (restricted)
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<Select disabled>
<SelectTrigger aria-label="Unavailable role">
<SelectValue placeholder="Managed by administrator" />
</SelectTrigger>
</Select>
<p className="text-sm text-muted-foreground">Selected: {role}</p>
</div>
);
}Usage
Compose the trigger, value, content, and items. Use SelectGroup and SelectLabel to organize related options. Use a combobox for searchable lists.
import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
SelectGroup,
SelectLabel,
} from "@dashboardpack/core/components/ui/select";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| value / defaultValue | stringDefault: — | Selected item value. |
| onValueChange | (value: string) => voidDefault: — | Handle a selected option. |
| disabled | booleanDefault: false | Disable the entire select. |
| placeholder (SelectValue) | stringDefault: — | Text shown before selection. |