Command Palette

⌘K launcher with fuzzy matching, highlighted letters, groups and full keyboard control.

  • Zero dependencies
  • React + Tailwind
  • Accessible
  • Reduced-motion aware
Open in v0

Preview

Animated · Full motion: idle animation, physics and effects. animated (default)

Bring your own items and handle onSelect. Fuzzy scoring prefers consecutive and word-start matches. This exact component powers search on this site (press ⌘K).

Installation

$ npx shadcn@latest add https://pickui.guetix.com/r/command-palette.json

Uses the shadcn CLI. It creates components/pickui/command-palette.tsx and installs nothing else.

Usage

example.tsx
"use client";

import { useState } from "react";
import CommandPalette, { type CommandItem } from "@/components/pickui/command-palette";

const ITEMS: CommandItem[] = [
  { id: "new", label: "Create new project", group: "Actions", hint: "N" },
  { id: "deploy", label: "Deploy to production", group: "Actions", hint: "⇧D" },
  { id: "invite", label: "Invite teammate", group: "Actions" },
  { id: "billing", label: "Billing & invoices", group: "Navigation", keywords: ["payment", "plan"] },
  { id: "settings", label: "Settings", group: "Navigation", keywords: ["preferences"] },
  { id: "logs", label: "Runtime logs", group: "Navigation" },
  { id: "docs", label: "Read the docs", group: "Help" },
  { id: "shortcuts", label: "Keyboard shortcuts", group: "Help", hint: "?" },
];

export default function CommandPaletteDemo({ variant = "animated" }: { variant?: string }) {
  const [picked, setPicked] = useState<string | null>(null);
  return (
    <div className="flex flex-col items-center gap-4">
      {/* hotkey disabled here so it doesn't fight the site's own ⌘K */}
      <CommandPalette items={ITEMS} onSelect={(it) => setPicked(it.label)} hotkey={null} placeholder="Type a command or search…" animated={variant !== "regular"} />
      <p className="font-mono text-xs text-white/50" aria-live="polite">
        {picked ? `→ ${picked}` : "Click the bar, type “dep” or “bill”"}
      </p>
    </div>
  );
}
App searchDocsAdmin dashboards

Under the hood

The details that make it feel right, and that a one-line prompt usually misses:

  • 01Subsequence scoring with bonuses for consecutive and word-start hits.
  • 02Restores focus to where you were when it closes.

Props

PropTypeDefaultDescription
items{ id; label; group?; hint?; description?; keywords?; icon? }[]—Commands.
onSelect(item) => void—Handler.
open / onOpenChangeboolean—Controlled state.
hotkeystring | null"k"Letter with ⌘/Ctrl.
suggestionsstring[]—Quick-search chips shown while the query is empty.
recentKeystring—localStorage key: remembers the last 5 picks and lists them first.
animatedbooleantruefalse = the calm “Regular” version (no idle or ambient motion).

Accessibility

  • Dialog + combobox/listbox pattern with aria-activedescendant.