codefast/ui

Command Palette

Search for a command to run...

Overlay

Command

Command palette with fuzzy search, groups, keyboard shortcuts, and empty state.

Install

pnpm add @codefast/ui

Import path

@codefast/ui/command

Examples

Command dialog

The same palette in a modal — the most common ⌘K pattern.

Press J

Command Palette

Search for a command to run...

Basic

A simple command menu in a dialog.

Command Palette

Search for a command to run...

Groups

A command menu with groups, icons and separators.

Command Palette

Search for a command to run...

RTL

Right-to-left layout support for languages such as Arabic and Hebrew.

Translations are AI-generated for demonstration and may be imperfect.

Scrollable

Scrollable command menu with multiple items.

Command Palette

Search for a command to run...

Shortcuts

Command menu for search and quick actions.

Command Palette

Search for a command to run...

Anatomy

How the parts compose. Copy this skeleton and fill in the slots.

import {
  Command, CommandInput, CommandList,
  CommandEmpty, CommandGroup, CommandItem,
} from "@codefast/ui/command";

<Command>
  <CommandInput placeholder="Search…" />
  <CommandList>
    <CommandEmpty>No results.</CommandEmpty>
    <CommandGroup heading="">
      <CommandItem onSelect={run}>…</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

API reference

Props for each part of the component. All native element props are also forwarded.

Command

Built on cmdk. Filters items by the input as you type.

PropTypeDefaultDescription
value / onValueChangestring / (value: string) => voidControl the highlighted item.
shouldFilterbooleantrueTurn off built-in filtering to filter server-side.

CommandItem

PropTypeDefaultDescription
onSelect(value: string) => voidRuns when the item is chosen by click or Enter.
disabledbooleanfalseSkip the item during filtering and keyboard nav.

CommandDialog

Command inside a Dialog.

PropTypeDefaultDescription
open / onOpenChangeboolean / (open: boolean) => voidControl the modal palette’s visibility.

Accessibility

Built to be keyboard-navigable and screen-reader friendly out of the box.

KeyFunction
Arrow+DownHighlights the next item.
Arrow+UpHighlights the previous item.
EnterRuns the highlighted item.
EscCloses the command dialog.
  • The input is a combobox controlling a listbox; highlighting is announced.
  • Always provide a CommandEmpty so an empty search is communicated.
  • Bind ⌘K / Ctrl+K to open the dialog in real apps — shown here as a hint only.

Guidelines

Conventions that keep usage consistent across an app.

Do

  • Group commands and add a short heading per group.
  • Show shortcuts with CommandShortcut so power users learn them.

Don’t

  • Don’t hide the only path to an action behind the palette.
  • Don’t list hundreds of flat items without groups or search hints.