Documentation
Combobox
Advanced searchable combobox with async API support, rich display, grouping, infinite scroll, and create new options.
Installation
pnpm add @rouf-dev/pantheon-ui cmdkUsage
Basic Static Options
import { Combobox } from "@rouf-dev/pantheon-ui";
<Combobox
options={[
{ value: "next", label: "Next.js" },
{ value: "react", label: "React" },
{ value: "vue", label: "Vue.js" },
]}
placeholder="Select framework..."
value={value}
onValueChange={setValue}
/>Async API Search
// Use onSearch prop for async data fetching
<Combobox
onSearch={async (query) => {
const res = await fetch(`/api/users?q=${query}`);
return res.json();
}}
debounceMs={500}
minSearchLength={2}
placeholder="Search users..."
value={value}
onValueChange={setValue}
/>Rich Display with Avatars
<Combobox
options={users.map(u => ({
value: u.id,
label: u.name,
description: u.email,
avatar: u.avatarUrl
}))}
richDisplay
placeholder="Select user..."
value={value}
onValueChange={setValue}
/>With Create New Option
<Combobox
options={tags}
allowCreate
createText="Create tag"
onCreate={(query) => createTag(query)}
placeholder="Select or create tag..."
value={value}
onValueChange={setValue}
/>Features
- Static options or async API search with
onSearch - Rich display mode with avatars and descriptions
- Grouped options by category
- Create new option on the fly
- Infinite scroll support
- Customizable debounce and minimum search length
- Custom render functions for options and values