docs/components/select
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Displays a list of options.
PreviewCode
Select a fruit
BananaAppleOrangePineapple
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/select
Select
├── SelectTrigger
│ └── SelectValue
└── SelectContent
├── SelectEmpty
├── SelectClearTrigger
├── SelectGroup
│ ├── SelectGroupLabel
│ └── SelectItem
└── SelectItem
import { createListCollection } from "@ark-ui/react";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
const collection = createListCollection({
items: ["Option 1", "Option 2", "Option 3"],
});
<Select collection={collection}>
<SelectTrigger>
<SelectValue placeholder="Select an option" />
</SelectTrigger>
<SelectContent>
{collection.items.map((item) => (
<SelectItem item={item} key={item}>
{item}
</SelectItem>
))}
</SelectContent>
</Select>
Use value and onValueChange to control the selected items.
PreviewCode
React
ReactVueSvelte
Control trigger size with the size prop on SelectTrigger.
PreviewCode
Select framework
Next.jsViteESBuild
PreviewCode
Select framework
Next.jsViteESBuild
PreviewCode
Select framework
Next.jsViteESBuild
PreviewCode
Select framework
Next.jsViteAstro
PreviewCode
Select framework
Next.jsViteAstro
Enable multiple selection with the multiple prop.
PreviewCode
javascript (+1 more)
JavaScriptTypeScriptPythonRust
Organize options into groups using groupBy and SelectGroup.
PreviewCode
Select framework
Next.jsViteAstroExpressFastifyNestJS
Use Field for labels, helper text, and error handling.
PreviewCode
Country
Select a country
BrazilMexicoIreland
Used for shipping estimates
PreviewCode
Select 3 frameworks
JavaScriptTypeScriptPythonRust
PreviewCode
Select framework
Framework 1Framework 2Framework 3Framework 4Framework 5Framework 6Framework 7Framework 8Framework 9Framework 10Framework 11Framework 12Framework 13Framework 14Framework 15Framework 16Framework 17Framework 18Framework 19Framework 20
Use SelectEmpty to display a message when the collection has no items.
PreviewCode
Select an option
Root component.
| Prop | Type | Default |
|---|---|---|
collection | ListCollection<T> | - |
value | string[] | - |
defaultValue | string[] | - |
onValueChange | (details: ValueChangeDetails<T>) => void | - |
multiple | boolean | false |
disabled | boolean | - |
invalid | boolean | - |
name | string | - |
required | boolean | - |
positioning | PositioningOptions | - |
lazyMount | boolean | true |
unmountOnExit | boolean | true |
className | string | - |
Opens the dropdown on click. Displays the selected value or placeholder.
| Prop | Type | Default |
|---|---|---|
size | `"sm" | "md" |
showClear | boolean | false |
className | string | - |
asChild | boolean | - |
Shows the selected value or placeholder. Use SelectContext as children for custom display.
| Prop | Type | Default |
|---|---|---|
placeholder | string | - |
className | string | - |
asChild | boolean | - |
Holds the dropdown options. Displayed in a portal.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Button to clear the selected value. Shown when showClear is true on SelectTrigger.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
Groups related options under an optional heading.
| Prop | Type | Default |
|---|---|---|
heading | string | ReactNode |
className | string | - |
asChild | boolean | - |
Label for an option group.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | - |
A single selectable option in the dropdown.
| Prop | Type | Default |
|---|---|---|
item | T | - |
className | string | - |
asChild | boolean | - |
Shown when the collection has no items (collection.size === 0). Place inside SelectContent.
| Prop | Type | Default |
|---|---|---|
className | string | - |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Segment Group ](/docs/components/segment-group)[
Next page
Separator ](/docs/components/separator)
On This Page
InstallationAnatomyUsageControlledSizeSmallMediumLargeStatesDisabledInvalidExamplesMultipleGroupingWith FieldMax SelectionScrollableEmptyAPI ReferenceSelectSelectTriggerSelectValueSelectContentSelectClearTriggerSelectGroupSelectGroupLabelSelectItemSelectEmpty