List Box

Loading...

Installation

Add the component with the CLI.

npx shadcn@latest add @intentui/list-box

Composed components

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

Manual installation

Install the dependencies, then copy the component source into your project.

npm install react-aria-components @heroicons/react cn

Anatomy

import { ListBox, ListBoxItem } from "@/components/ui/list-box"
<ListBox aria-label="Bands">
  <ListBoxItem>Nirvana</ListBoxItem>
  <ListBoxItem>Radiohead</ListBoxItem>
  <ListBoxItem>Foo Fighters</ListBoxItem>
  <ListBoxItem>Arctic Monkeys</ListBoxItem>
  <ListBoxItem>The Strokes</ListBoxItem>
</ListBox>

Examples

Multiple selection

Set selectionMode="multiple" to allow multiple selections.

Loading...

Description

Add supporting text with ListBoxDescription.

Loading...

Section

Group items in a ListBox using sections for better organization.

Loading...

Drag and drop

Enable drag-and-drop functionality in the ListBox by using the dragAndDropHooks prop with the useDragAndDrop hook. This allows users to rearrange items, insert new entries, or manage data across the list.

Loading...

Infinite scrolling

Load more items as users scroll with infinite scrolling.

Loading...

Controlled

For controlled selection, pass selectedKeys and update it with onSelectionChange. Set selectionMode="single" to allow one selected item.

Loading...

Disabled

Disable specific ListBox items to restrict user interaction.

Loading...

You can also disable an item directly by passing the isDisabled prop to ListBoxItem.

<ListBoxItem isDisabled>Disabled</ListBoxItem>

Component API

ListBox

ListBox extends the React Aria Components <ListBox> component.

classNamestring

ListBoxItem

ListBoxItem extends the React Aria Components <ListBoxItem> component.

classNamestring

ListBoxLabel

ListBoxLabel extends the Intent UI <DropdownLabel> component.

classNamestring

ListBoxDescription

ListBoxDescription extends the Intent UI <DropdownDescription> component.

classNamestring

ListBoxSection

ListBoxSection extends the React Aria Components <ListBoxSection> component.

classNamestring

See the React Aria for the full API reference.

Design