Navigation

Command

A fast, composable command palette with fuzzy search, ideal for keyboard-driven power users.

Preview
01 Installation

Install

Pull Command from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Command } from "@brika/clay";
tsxGranular1 line
import { Command } from "@brika/clay/components/command";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxCommand.tsx57 lines
'use client';

import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandSeparator,
  CommandShortcut,
} from '@brika/clay/components/command';
import {
  Calculator,
  Calendar,
  FileText,
  Settings,
  User,
} from 'lucide-react';
/** Inline command palette with grouped items, icons, and keyboard shortcuts. */
export default function CommandDefaultDemo() {
  return (
    <Command className="rounded-lg border shadow-md w-72">
      <CommandInput placeholder="Type a command or search..." />
      <CommandList>
        <CommandEmpty>No results found.</CommandEmpty>
        <CommandGroup heading="Suggestions">
          <CommandItem>
            <Calendar />
            Calendar
          </CommandItem>
          <CommandItem>
            <Calculator />
            Calculator
          </CommandItem>
          <CommandItem>
            <FileText />
            New document
          </CommandItem>
        </CommandGroup>
        <CommandSeparator />
        <CommandGroup heading="Settings">
          <CommandItem>
            <User />
            Profile
            <CommandShortcut>⌘P</CommandShortcut>
          </CommandItem>
          <CommandItem>
            <Settings />
            Settings
            <CommandShortcut>⌘S</CommandShortcut>
          </CommandItem>
        </CommandGroup>
      </CommandList>
    </Command>
  );
}
03 Examples

Command, every way

Dialog

Modal command palette triggered by Cmd+K, the standard power-user pattern.

Groups

Three groups, Suggestions, Recent, and Settings, with icons on every item.

Navbar-style search bar: CommandInputControl embedded in an InputGroup for the focus halo, with CommandList rendered as an absolute dropdown below. The Command palette mode and this detached mode are fully independent parts of the same component tree.

04 Accessibility

Accessibility

  • Arrow keys navigate list items; Enter activates the focused item.
  • The input is always focused while the list is visible, Tab closes the command palette.
  • Grouped items announce their group heading; CommandEmpty is announced when no results match.
  • Wrap in CommandDialog for modal use, adds focus trapping and Escape-to-close.
05 Tokens 17 theme-overridable

Theme tokens

Every CSS variable Command reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Command without touching component code.

Command tokens

17 tokens
ColorFill, border, and text colors.9
  • --command-surface-containercolorvar(--popover)
    components.command.surfaceContainer

    Background of the command palette surface.

  • --command-surface-labelcolorvar(--popover-foreground)
    components.command.surfaceLabel

    Default foreground color inside the command palette.

  • --command-separator-colorcolorvar(--border)
    components.command.separatorColor

    Color of the divider rule between command palette groups.

  • --command-input-border-colorcolorvar(--border)
    components.command.inputBorderColor

    Color of the bottom border under the command input row.

  • --command-shortcut-colorcolorvar(--muted-foreground)
    components.command.shortcutColor

    Color of the keyboard-shortcut hint inside command items.

  • --command-icon-colorcolorvar(--muted-foreground)
    components.command.iconColor

    Default color of inline SVG icons inside command items.

  • --command-group-heading-colorcolorvar(--muted-foreground)
    components.command.groupHeadingColor

    Foreground color of the group heading rendered above grouped items.

  • --command-placeholder-colorcolorvar(--muted-foreground)
    components.command.placeholderColor

    Foreground color of the input placeholder in the command search field.

  • --command-empty-colorcolorvar(--muted-foreground)
    components.command.emptyColor

    Foreground color of the empty-results message.

GeometrySizes, lengths, and corner radii.4
  • --command-radiusradiusvar(--radius-surface)
    components.command.radius

    Command palette container radius.

  • --command-padding-xsize0px
    components.command.paddingX

    Inline padding inside the command.

  • --command-padding-ysize0px
    components.command.paddingY

    Block padding inside the command.

  • --command-gapsize0px
    components.command.gap

    Gap between adjacent children inside the command.

BorderBorder width and style.2
  • --command-border-widthborder-width1px
    components.command.borderWidth

    Border width on the command. Set non-zero for outline-style variants.

  • --command-border-styleborder-stylesolid
    components.command.borderStyle

    Border style on the command (`solid`, `dashed`, `double`, `none`).

ElevationDrop shadow and depth.2
  • --command-shadowshadowvar(--shadow-overlay)
    components.command.shadow

    Command palette elevation.

  • --command-backdrop-blurblur0px
    components.command.backdropBlur

    Backdrop blur on the command palette container. Set non-zero for a frosted-glass overlay.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.command, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "command": {
      "paddingX": "0px"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-command-…) — see the chips on each token row.

06 API reference

API reference

Props specific to Command. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

<Command />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandDialog />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandEmpty />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandGroup />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandInput />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandInputControl />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandItem />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandList />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandSeparator />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CommandShortcut />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.