docs/components/listbox
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Select a single or multiple items from a list.
PreviewCode
Brazil
Mexico
Ireland
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/listbox
Listbox
├── ListboxValueText
└── ListboxContent
├── ListboxEmpty
└── ListboxItemGroup
├── ListboxItemGroupLabel
└── ListboxItem
├── ListboxItemText
├── ListboxItemIndicator
└── ListboxShortcut
import { createListCollection } from "@ark-ui/react";
import {
Listbox,
ListboxContent,
ListboxItem,
ListboxLabel,
} from "@/components/ui/listbox";
const collection = createListCollection({
items: [
{ label: "Brazil", value: "br" },
{ label: "Mexico", value: "mx" },
{ label: "Ireland", value: "ie" },
],
});
<Listbox collection={collection}>
<ListboxContent>
{collection.items.map((item) => (
<ListboxItem item={item} key={item.value}>
{item.label}
</ListboxItem>
))}
</ListboxContent>
</Listbox>
Use value and onValueChange to control the listbox externally.
PreviewCode
Selected the Large size
Small
Medium
Large
Extra Large
❌
Disable the entire listbox with the disabled prop.
PreviewCode
Brazil
Mexico
Ireland
Use orientation prop to change the orientation of the listbox.
PreviewCode
Favorite album
Rappa Mundi
O Rappa
Acústico MTV
Charlie Brown Jr.
Thriller
Michael Jackson
The Eminem Show
Eminem
Set selectionMode="multiple" to allow selecting multiple items.
PreviewCode
Brazil
Mexico
Ireland
Set selectionMode="extended" to select multiple items with Cmd/Ctrl modifier.
PreviewCode
Hold ⌘ or Ctrl to select multiple
Brazil
Mexico
Ireland
Set selectionMode="none" to disable selection.
PreviewCode
Actions
New file Create a new file ⌘N
Edit file Make changes ⌘E
Danger zone
Delete file Move to trash ⌘D
PreviewCode
🇧🇷 Brazil
🇲🇽 Mexico
🇮🇪 Ireland
PreviewCode
Brazil South America's country, Portuguese speaking.
Mexico North America's country, Spanish speaking.
Ireland Europe's country, Irish/English speaking.
PreviewCode
Mountain Landscape
Ocean Waves
Forest Path
City Skyline
Desert Dunes
Scenic mountain view
PreviewCode
Available
Brazil
Ireland
Selected
Mexico
Use groupBy in createListCollection and <ListboxItemGroup heading={}> with <ListboxItemGroupLabel> to group items.
PreviewCode
South America
Brazil
Colombia
North America
Mexico
Canada
Filter items using useListCollection with useFilter from @ark-ui/react. Call filter when the search input changes to filter items by label.
PreviewCode
Brazil
Mexico
Ireland
Use the listbox within a popover to create dropdown-like selection menus that overlay other content without taking up permanent screen space.
PreviewCode
Select framework
Use createGridCollection with columnCount and grid CSS for a grid layout.
PreviewCode
😀
😍
🥳
😎
🤩
😂
🥰
😊
🤗
😇
🔥
✨
💯
🎉
❤️
👍
👏
🚀
⭐
🌈
Root component. Manages selection state and keyboard navigation.
| Prop | Type | Default |
|---|---|---|
collection | ListCollection<T> | required |
value | string[] | - |
defaultValue | string[] | [] |
onValueChange | (details: ValueChangeDetails<T>) => void | - |
selectionMode | `"single" | "multiple" |
orientation | `"vertical" | "horizontal"` |
disabled | boolean | - |
deselectable | boolean | - |
loopFocus | boolean | false |
Holds the list of options.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
className | string | - |
A single selectable list option.
| Prop | Type | Default |
|---|---|---|
item | T | required |
variant | `"default" | "destructive"` |
asChild | boolean | - |
highlightOnHover | boolean | - |
Text content for a list item.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
className | string | - |
Checkmark or icon shown when the item is selected.
| Prop | Type | Default |
|---|---|---|
children | ReactNode | CheckIcon |
asChild | boolean | - |
className | string | - |
Groups related options. Use heading or ListboxItemGroupLabel for a label.
| Prop | Type | Default |
|---|---|---|
heading | string | - |
asChild | boolean | - |
className | string | - |
Label for a group. Must be used inside ListboxItemGroup.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
className | string | - |
Shows the selected value(s) as text. Use for custom trigger or display.
| Prop | Type | Default |
|---|---|---|
placeholder | string | - |
asChild | boolean | - |
className | string | - |
Shown when the list has no items. Use for empty states.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | - |
className | string | - |
Optional keyboard shortcut hint shown next to an item.
For a complete list of props, see the Ark UI documentation.
[
Previous page
Link Overlay ](/docs/components/link-overlay)[
Next page
Marquee ](/docs/components/marquee)
On This Page
InstallationAnatomyUsageControlledStatesDisabledOrientationHorizontalSelection ModeMultipleExtendedNoneExamplesWith IconWith DescriptionImage ExplorerTransfer ListGroupingWith FilterWith PopoverGrid LayoutAPI ReferenceListboxListboxContentListboxItemListboxItemTextListboxItemIndicatorListboxItemGroupListboxItemGroupLabelListboxValueTextListboxEmptyListboxShortcut