Components
HeroUI v3 ListBox — an accessible, keyboard-navigable list of selectable options with single and multiple selection, sections with headers, per-item labels, descriptions, avatars and keyboard-shortcut hints, disabled items, custom selection indicators, controlled selection state, custom render functions, and windowed virtualization for large datasets. A thin re-export of the genuine @heroui/react package with @heroui/styles, so consumers install and render the real HeroUI primitive.
npx @21st-dev/cli@beta add hero_ui/heroui-list-boxLoading preview...
"use client"
import { FilePlus, Pencil, Trash2 } from "lucide-react"
import {
Description,
Header,
Kbd,
Label,
ListBox,
Separator,
Surface,
} from "@/components/ui/heroui-list-box"
export default function WithDisabledItems() {
return (
<Surface className="w-[256px] rounded-3xl shadow-surface">
<ListBox
aria-label="File actions"
className="w-full p-2"
disabledKeys={["delete-file"]}
selectionMode="none"
onAction={(key) => alert(`Selected item: ${key}`)}
>
<ListBox.Section>
<Header>Actions</Header>
<ListBox.Item id="new-file" textValue="New file">
<div className="flex h-8 items-start justify-center pt-px">
<FilePlus className="size-4 shrink-0 text-muted" />
</div>
<div className="flex flex-col">
<Label>New file</Label>
<Description>Create a new file</Description>
</div>
<Kbd className="ms-auto" variant="light">
<Kbd.Abbr keyValue="command" />
<Kbd.Content>N</Kbd.Content>
</Kbd>
</ListBox.Item>
<ListBox.Item id="edit-file" textValue="Edit file">
<div className="flex h-8 items-start justify-center pt-px">
<Pencil className="size-4 shrink-0 text-muted" />
</div>
<div className="flex flex-col">
<Label>Edit file</Label>
<Description>Make changes</Description>
</div>
<Kbd className="ms-auto" variant="light">
<Kbd.Abbr keyValue="command" />
<Kbd.Content>E</Kbd.Content>
</Kbd>
</ListBox.Item>
</ListBox.Section>
<Separator />
<ListBox.Section>
<Header>Danger zone</Header>
<ListBox.Item id="delete-file" textValue="Delete file" variant="danger">
<div className="flex h-8 items-start justify-center pt-px">
<Trash2 className="size-4 shrink-0 text-danger" />
</div>
<div className="flex flex-col">
<Label>Delete file</Label>
<Description>Move to trash</Description>
</div>
<Kbd className="ms-auto" variant="light">
<Kbd.Abbr keyValue="command" />
<Kbd.Abbr keyValue="shift" />
<Kbd.Content>D</Kbd.Content>
</Kbd>
</ListBox.Item>
</ListBox.Section>
</ListBox>
</Surface>
)
}
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...