Skip to content
GitHub (opens in a new tab)

Command

Searchable command menu for quick actions.

stableOrganismcontracts/command.json

Preview

Command

Searchable command menu for quick actions.

Master

Kit Button opens kit Modal with Command. ⌘K or Ctrl+K toggles it. No CommandDialog.

Usage

Command is the list. A kit Button or ⌘K opens it in a kit Modal, so it never flips or floats. Rows are 40px with the same anatomy as DropdownMenu. If people type to find it, use Command. If they act on one thing, use DropdownMenu. If they pick a value to save, use Select.

Do's

  • Searchable actions and quick jumps: many items, recent items or async results
  • Command palette — kit Button (or ⌘K) opens kit Modal with Command inside
  • Which one: if people type to find it, use Command. If they act on one thing, use DropdownMenu. If they pick a value to save, use Select.

Don'ts

  • Short Field dropdown — use Select
  • Actions from a button — use DropdownMenu
  • Sidebar navigation — use SideNav (product) or DocsNav (docs/catalog)
  • Overlay chrome — compose Modal; do not add CommandDialog
<>
  <Button appearance="outline" mode="neutral" iconStart="Search" onClick={() => setOpen(true)}>
    Open command
  </Button>
  <Modal open={open} title="Command menu" onClose={() => setOpen(false)}>
    <Command
      placeholder="Search pages and actions"
      groups={groups}
      onSelect={() => setOpen(false)}
      onAsk={() => setOpen(false)}
    />
  </Modal>
</>

When to use

  • Searchable actions and quick jumps: many items, recent items or async results
  • Command palette — kit Button (or ⌘K) opens kit Modal with Command inside
  • Which one: if people type to find it, use Command. If they act on one thing, use DropdownMenu. If they pick a value to save, use Select.

When not to use

  • Short Field dropdown — use Select
  • Actions from a button — use DropdownMenu
  • Sidebar navigation — use SideNav (product) or DocsNav (docs/catalog)
  • Overlay chrome — compose Modal; do not add CommandDialog

What an agent reads

import { Command } from "agentic-ds-kit";
must
  • Input is role=combobox with aria-expanded=true, aria-controls the listbox, aria-autocomplete=list, aria-activedescendant, and aria-label from label
  • List is role=listbox
  • Items are role=option with aria-selected when highlighted and aria-disabled when disabled. An item with a shortcut sets aria-keyshortcuts for a chord (e.g. Shift+Meta+P); a sequence such as G I is read as "G then I"; key chips and the key footer are hidden on touch screens and below --grid-breakpoint-sm (the keys still work)
  • useId for ids
  • Search icon is aria-hidden
  • Group headings are visible text in sentence case (no text-transform); inside a kit Modal, Command drops its own frame and the Modal card is the only one, and the search row is drawn as a field with kit Input's border, fill and focus ring, with the Esc hint at its end
  • Shortcut chips are Geist Mono, one chip per key, and aria-hidden
  • A polite live region reads the result count (resultCount label) after each search
  • The key footer (↑↓ navigate, ↵ open, Esc close) is aria-hidden; Esc hints show only inside a kit Modal
  • Rows are lg (40px) with a bg tray highlight and 2px radius (radius-control-sm), the same item anatomy as DropdownMenu; inside a kit Modal the highlight is bg.trayFloating. Like DropdownMenu, the highlighted row is a fill with no outline; the focus ring shows only on real :focus-visible, which here is the search field (rows take aria-activedescendant, not focus)
  • Placement: Command stays put. It always opens in a kit Modal, so it never flips or floats
  • built-in labels (navigate, openItem, close, resultCount) come from KitLabelsProvider; English by default
  • loading sets aria-busy on the listbox and shows kit Spinner (role=status)
  • The onAsk row is a role=option at the end of the list, reachable with the arrows like any item
  • Highlight: the fill is one decorative layer (aria-hidden) that glides to the highlighted row on hover and arrow keys (clip-path only, --motion-expand-*); it lands in place on first show, after the pointer leaves and on resize or scroll, and jumps with no slide under prefers-reduced-motion. Roles, aria-selected, aria-activedescendant and focus order are unchanged and the focus ring stays on the search field
defaults
  • placeholder Type a command or search...
  • empty No results found.
  • label Command menu
  • loading false
stops if
  • Do not invent CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut, or CommandDialog
  • Do not wrap the search field in Field — Command owns its input
  • Do not use kit Input (uncontrolled) for the query
  • Do not use cmdk or extra dependencies
  • Do not use raw hex
  • Do not close itself — compose Modal for an overlay

From contracts/command.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
placeholderstringNoType a command or search...—
emptystringNoNo results found.—
groupsarrayYes—Each group has optional heading and a required items array. Item icon: A curated Lucide name (PascalCase or kebab-case) renders instantly; any other Lucide name needs import "agentic-ds-kit/icons-on-demand" once (otherwise it is skipped with a dev warning). Or pass the Lucide component (Plus) or an element. Recent items are a plain group with heading "Recent".
onSelectfunctionNo—(id: string) => void
labelstringNoCommand menuAccessible name on the combobox input
loadingbooleanNofalseAsync results on the way: a kit Spinner row and aria-busy on the list. Items already passed stay visible.
onAskfunctionNo—(query: string) => void. Adds an Ask Chat row (MessageCircle) at the foot of the list and in the empty state.
  • Component
    →

    Field

    One labeled control with optional hint and an error or success message.

  • Component
    →

    Select

    Choose one or several options from a list.

  • Component
    →

    DropdownMenu

    Actions or value menu from a button, field, or nav trigger.

  • Component
    →

    SideNav

    Product side nav: brand header, icon items, optional badges, closeable; variant single (one column that closes to an icon rail) or rail-subnav (a fixed icon rail plus a SideNav.SubNav column with the picked parent's rows).