Skip to content

Command

Keyboard-first command palette / filterable menu. Compound API with case-insensitive substring filter, groups, and full a11y (combobox/listbox/option).

Overlays & Feedback@sisyphos-ui/commandView on npmView as Markdown

Preview

tsx
No results.
Suggestions
Settings

Installation

Install the individual package:

$ pnpm add @sisyphos-ui/command @sisyphos-ui/core

Or use the umbrella package that bundles everything:

$ pnpm add @sisyphos-ui/ui

Usage

Import the component styles and the component itself:

snippet.tsxtsx
import "@sisyphos-ui/command/styles.css";
import { Command } from "@sisyphos-ui/command";

Anatomy

The Command is a compound component. Compose the parts that match your use case.

Anatomy
<Command.Root>
  <Command.Input />// Text input that drives the filter.required
  <Command.List />// Scrollable listbox region.required
  <Command.Empty />// Rendered when no items match.
  <Command.Group />// Optional section with an `heading`.
  <Command.Item />// Selectable row filtered by `value`.required
  <Command.Separator />// Visual divider.
</Command.Root>

Inside a Dialog

The classic ⌘K experience — drop `<Command>` inside `<Dialog>` and the input takes focus on open.

tsx

With shortcuts

Drop a `<Kbd>` inside each `<Command.Item>` — it flows to the right automatically via `margin-left: auto` on the flex row.

tsx
File

Disabled items

`disabled` items are still rendered but don't match, aren't focusable, and can't be activated.

tsx

API

PropTypeDefaultDescription
valuestringControlled search value. Omit to let the component manage its own state.
defaultValuestring""Initial search value when uncontrolled.
onValueChange(value: string) => voidFires whenever the search value changes.
onSelect(value: string) => voidFires when an item is activated (click or Enter). Receives the item's `value` prop.
labelstring"Command menu"Accessible name for the combobox root.

The full API including refs, ARIA attributes, and HTML passthroughs lives in the package README.

Accessibility

Adheres to the Combobox WAI-ARIA design pattern.

Keyboard interactions

KeyAction
ArrowDownthenArrowUpMove the active item (wraps at the edges).
HomethenEndFirst / last matching item.
EnterActivate the current item.
Was this page helpful?