Components/CommandPalette

CommandPalette

A Cmd+K command palette with fuzzy search, grouped results, keyboard navigation (↑↓↵), and shortcut display. The useCommandPalette hook auto-binds Cmd/Ctrl+K.

import { CommandPalette, useCommandPalette } from "@animui/ui"

Live demo

Press Ctrl+K or click the button to open.

Grouped items

Assign a group string to each command item — items with the same group are shown under a shared heading.

command-items.ts
const commands = [
  { id: "new-file",   label: "New file",      group: "Create", onSelect: () => {} },
  { id: "new-folder", label: "New folder",    group: "Create", onSelect: () => {} },
  { id: "profile",    label: "Go to profile", group: "Navigate", onSelect: () => {} },
  { id: "settings",  label: "Settings",      group: "Navigate", onSelect: () => {} },
  { id: "logout",    label: "Sign out",      group: "Account", onSelect: () => {} },
];

CommandPalette props

PropTypeDefaultDescription
openbooleanWhether the palette is shown.
onClose() => voidCalled when the user dismisses the palette (Escape or backdrop click).
itemsCommandItem[]Array of command items to display and search.
placeholderstring"Search commands…"Input placeholder text.
classNamestringAdditional classes on the panel.

useCommandPalette hook

PropTypeDefaultDescription
openbooleanfalseWhether the palette is currently open.
setOpen(open: boolean) => voidToggle open state.
close() => voidClose the palette.

CommandItem shape

PropTypeDefaultDescription
idstringUnique identifier.
labelstringPrimary display text.
descriptionstringSecondary description shown below the label.
iconReactNodeIcon rendered before the label.
groupstringGroup heading to organize items.
shortcutstring[]Keyboard shortcut keys shown as badges.
onSelect() => voidAction to run when selected.
© 2026 Steal Shadow. MIT License.Report an issue