bx

Command

Fast, composable, unstyled command menu.

Suggestions
Calendar
Search Emoji
Calculator
Settings
Profile
Billing
tsx
<Command>
  <CommandInput placeholder="Type a command..." />
  <CommandList>
    <CommandGroup heading="Suggestions">
      <CommandItem>Calendar</CommandItem>
      <CommandItem>Search Emoji</CommandItem>
    </CommandGroup>
    <CommandSeparator />
    <CommandGroup heading="Settings">
      <CommandItem>Profile</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Command is a command palette (fuzzy search and keyboard navigation). It is the ⌘K pattern popularized by Linear and Raycast: the user types, the list filters in real time, and Enter activates the focused item.

It can be used standalone (in a side panel) or embedded in a Dialog for a ⌘K modal.

Installation

Terminal
$ bext ui add command

Usage

tsx
import { Command, CommandInput, CommandList, CommandGroup, CommandItem, CommandSeparator } from "@bext-stack/ui/primitives"

<Command>
  <CommandInput placeholder="Type a command..." />
  <CommandList>
    <CommandGroup heading="Suggestions">
      <CommandItem>Calendar</CommandItem>
      <CommandItem>Search Emoji</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

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 of the search field.
className string — Input with a built-in search icon on the left.

CommandList

Prop Type Default Description
className string — Scrollable container for the items. max-h-[300px].

CommandGroup

Prop Type Default Description
heading string — Muted section title above the items.

CommandItem

Prop Type Default Description
href string — If set, renders <a>, otherwise <div>.
onSelect function — Callback on activation (Enter or click).

CommandSeparator

Prop Type Default Description
— — — Thin line between groups.

CommandEmpty

Prop Type Default Description
children ReactNode — Shown when no item matches.

Data Attributes

Attributes you can target in custom CSS to override the style for each state.

Attribute On Values Description
data-command root — Anchor for the fuzzy-search island.
data-command-item CommandItem — Each item is matched against its text.

Keyboard

Key Action
↑ / ↓ Moves between visible items.
Enter Activates the focused item.
Escape Closes (when inside a Dialog).
⌘K / Ctrl+K Convention for toggling a global command palette.

Accessibility

CommandInput must have role="combobox", aria-expanded, aria-autocomplete="list". The list carries role="listbox", each item role="option" aria-selected.

Without these attributes, screen readers do not announce the live filtering.

Try it live
Open in play

Edit this component live in the bext playground. The PRISM + signals version is the bext-native idiom: fine-grained reactivity, no virtual DOM.

src/app/page.tsx 2 files · signals · runs in your browser
Pure PRISM + real bext signals: fine-grained, no re-render.