shadcn.io is not affiliated with official shadcn/ui
Framework
UI library
Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.
Brazil
Mexico
Ireland
Installation
bunx --bun shadcn@latest add https://kit.dev/r/radix/listbox.jsonAnatomy
ListboxRoot
├── ListboxLabel
├── ListboxInput
├── ListboxItem
│ ├── ListboxItemText
│ ├── ListboxItemIndicator
│ └── ListboxItemGroup
│ └── ListboxItemGroupLabel
├── ListboxContent
└── ListboxValueTextUsage
import { createListCollection } from "@ark-ui/react/collection";
import {
Listbox,
ListboxContent,
ListboxItem,
ListboxItemIndicator,
ListboxItemText,
} from "@/components/ui/listbox";const Example = () => (
<Listbox
className="w-full max-w-64"
collection={collection}
defaultValue={["br"]}
>
<ListboxContent>
{collection.items.map((item) => (
<ListboxItem item={item} key={item.value}>
<ListboxItemText>{item.label}</ListboxItemText>
<ListboxItemIndicator />
</ListboxItem>
))}
</ListboxContent>
</Listbox>
);
const collection = createListCollection({
items: [
{ label: "Brazil", value: "br" },
{ label: "Mexico", value: "mx" },
{ label: "Ireland", value: "ie" },
],
});Accessibility
| Key | Description |
|---|---|
ArrowUp | Move up. |
ArrowDown | Move down. |
ArrowLeft | Move left. |
ArrowRight | Move right. |
Home | Go to the start. |
End | Go to the end. |
Enter | Activate the focused item. |
Ctrl+A | Select all. |
Space | Activate the focused item. |
Escape | Clear the selection. |
Demos
Controlled
Disabled
Disabled Item
Grid
Grouping
Horizontal
Image Explorer
Selection Extended
Selection Multiple
Selection None
Transfer List
With Description
With Filter
With Icon
With Popover
API Reference
ListboxItem
div
PropType
AttributeType
ListboxItemText
div
PropType
AttributeType
ListboxItemIndicator
div
PropType
AttributeType
ListboxItemGroup
div
PropType
AttributeType
ListboxItemGroupLabel
div
PropType
AttributeType
ListboxContent
div
PropType
AttributeType
CSS variableType
--column-countstringListboxValueText
span
PropType
AttributeType
ListboxEmpty
div
PropType
AttributeType
ListboxShortcut
PropType
AttributeType
useListbox
PropType