Skip to content

CommandPalette

A filterable command list with keyboard navigation. Takes an array of commands with name, description, and optional shortcut. Users type to filter and navigate with arrow keys / j/k. Uses fuzzy matching.

Import

tsx
import { CommandPalette } from "silvery"

Props

PropTypeDefaultDescription
commandsCommandItem[]requiredAvailable commands
onSelect(command: CommandItem) => void--Called when a command is selected (Enter)
onClose() => void--Called when the palette is dismissed (Escape)
placeholderstring"Search commands..."Placeholder text for filter input
maxVisiblenumber10Max visible results
isActivebooleantrueWhether this component captures input

CommandItem

ts
interface CommandItem {
  name: string // Command display name
  description?: string // Command description
  shortcut?: string // Keyboard shortcut hint
}

Keyboard Shortcuts

KeyAction
Printable charsFilter by name/description
BackspaceDelete last character
Up/DownNavigate results
EnterSelect command
EscapeDismiss palette

Usage

tsx
const commands = [
  { name: "Save", description: "Save current file", shortcut: "Ctrl+S" },
  { name: "Quit", description: "Exit application", shortcut: "Ctrl+Q" },
  { name: "Help", description: "Show help" },
]

<CommandPalette
  commands={commands}
  onSelect={(cmd) => exec(cmd.name)}
  onClose={() => setShowPalette(false)}
  placeholder="Type a command..."
/>

See Also

Released under the MIT License.