sigilUI

Command

Command palette with search, keyboard navigation, and grouped actions.

@sigil-ui/componentsReact

Command

Command palette with search, keyboard navigation, and grouped actions.

Installation

npx @sigil-ui/cli add command

Preview

Live preview Interactive

Import

import {
  Command,
  CommandInput,
  CommandList,
  CommandEmpty,
  CommandGroup,
  CommandItem,
  CommandSeparator,
  CommandDialog,
} from "@sigil-ui/components";

Usage

<Command>
  <CommandInput placeholder="Type a command..." />
  <CommandList>
    <CommandEmpty>No results found.</CommandEmpty>
    <CommandGroup heading="Actions">
      <CommandItem>New file</CommandItem>
      <CommandItem>New folder</CommandItem>
    </CommandGroup>
    <CommandSeparator />
    <CommandGroup heading="Settings">
      <CommandItem>Profile</CommandItem>
      <CommandItem>Preferences</CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Examples

As a dialog (⌘K)

const [open, setOpen] = useState(false);

useEffect(() => {
  const handler = (e: KeyboardEvent) => {
    if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
      e.preventDefault();
      setOpen((prev) => !prev);
    }
  };
  document.addEventListener("keydown", handler);
  return () => document.removeEventListener("keydown", handler);
}, []);

<CommandDialog open={open} onOpenChange={setOpen}>
  <CommandInput placeholder="Search..." />
  <CommandList>
    <CommandEmpty>No results.</CommandEmpty>
    <CommandGroup heading="Pages">
      <CommandItem>Dashboard</CommandItem>
      <CommandItem>Settings</CommandItem>
      <CommandItem>Billing</CommandItem>
    </CommandGroup>
  </CommandList>
</CommandDialog>

With icons

<Command>
  <CommandInput placeholder="Search..." />
  <CommandList>
    <CommandGroup heading="Navigation">
      <CommandItem>
        <HomeIcon className="mr-2 size-4" />
        Home
      </CommandItem>
      <CommandItem>
        <SettingsIcon className="mr-2 size-4" />
        Settings
      </CommandItem>
    </CommandGroup>
  </CommandList>
</Command>

Props

Command

PropTypeDefaultDescription
classNamestring—Additional CSS classes

CommandInput

PropTypeDefaultDescription
placeholderstring—Input placeholder text

CommandItem

PropTypeDefaultDescription
onSelect(value: string) => void—Selection handler
disabledbooleanfalseDisable this item

CommandDialog

PropTypeDefaultDescription
openboolean—Controlled open state
onOpenChange(open: boolean) => void—State change handler

Tokens

This component reads these CSS variables:

  • --s-background — command container and hover state
  • --s-border — input border, separator
  • --s-card-radius — container radius
  • --s-text — item text
  • --s-text-muted — placeholder, search icon, group heading
  • --s-shadow-lg — dialog elevation