Command
Fast, composable, unstyled command menu.
Command — palette de commandes (fuzzy-search + navigation clavier). Le pattern ⌘K populaire depuis Linear / Raycast — user tape, la liste filtre en temps réel, Enter active l'item focus.
Peut être utilisé standalone (dans un panel latéral) ou embarqué dans un Dialog pour un modal ⌘K.
Installation
$ bext ui add command
Copy and paste the following into src/components/ui/command.tsx.
This component is interactive — make sure the shared island is loaded (see Islands). It reacts to data-ui="command" hooks.
Usage
Anatomy
<Command>
├── <CommandInput placeholder="Type a command..." />
└── <CommandList>
├── <CommandGroup heading="Suggestions">
│ ├── <CommandItem>Calendar</CommandItem>
│ └── <CommandItem>Search Emoji</CommandItem>
├── <CommandSeparator />
└── <CommandGroup heading="Settings">
└── <CommandItem>Profile</CommandItem>API Reference
Command
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Wrapper flex flex-col overflow-hidden rounded-md border bg-popover. |
CommandInput
| Prop | Type | Default | Description |
|---|---|---|---|
| placeholder | string | — | Placeholder du champ recherche. |
| className | string | — | Input avec icône search intégrée à gauche. |
CommandList
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Container scrollable des items. max-h-[300px]. |
CommandGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | — | Titre de section muted au-dessus des items. |
CommandItem
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | — | Si présent, rend — sinon . |
| onSelect | function | — | Callback à l'activation (Enter ou clic). |
CommandSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
| — | — | — | Trait fin entre groupes. |
CommandEmpty
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | — | Affiché quand aucun item ne matche. |
Data Attributes
Attributs qu'on peut cibler en CSS custom pour override le style par état.
| Attribute | On | Values | Description |
|---|---|---|---|
| data-command | root | — | Ancre pour l'island de fuzzy-search. |
| data-command-item | CommandItem | — | Chaque item testable via matches sur le texte. |
Keyboard
| Key | Action |
|---|---|
| ↑ / ↓ | Navigation entre items visibles. |
| Enter | Active l'item focus. |
| Escape | Ferme (si dans un Dialog). |
| ⌘K / Ctrl+K | Convention pour toggle une command palette globale. |
Accessibility
CommandInput doit avoir role="combobox", aria-expanded, aria-autocomplete="list". La liste porte role="listbox", chaque item role="option" aria-selected.
Sans ces attributs le screen reader n'annonce pas le filtre live.
Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom — fine-grained reactivity, no virtual DOM.
On This Page