CommandPalette

Cmd+K palette. Type to filter, arrows move one highlight that stretches between rows, Enter runs. Overlays.

Open playground

About

CommandPalette is a React component in the Overlays category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CommandPalette } from "@ashutoshswamy/smoui" and set groups, trigger, open.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CommandPalette } from "@ashutoshswamy/smoui";

<CommandPalette
  trigger="Search"
  groups={[{ heading: "Suggestions", items: [{ id: "new", label: "New document", hint: "N", onSelect: create }] }]}
/>

Props 3

groups

Commands, grouped.

{ heading: string; items: { id; label; icon?; hint?; keywords?; onSelect? }[] }[]
trigger / shortcut

Opening button and the Cmd/Ctrl+K shortcut.

ReactNode / booleandefault - / true
open / onOpenChange

Controlled state.

boolean / (open: boolean) => void