Özer

Command Palette

Component 41

About

A keyboard-driven command palette with fuzzy search, arrow-key navigation, and an animated overlay for triggering app actions.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Command Palette to your project and fits it to your theme.

Code

How Command Palette is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

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

const commands: CommandItem[] = [
  { id: "new", label: "New document", hint: "Workspace", shortcut: ["⌘", "N"] },
  { id: "dup", label: "Duplicate document", keywords: "copy clone" },
  { id: "del", label: "Delete document", keywords: "remove trash" },
  { id: "share", label: "Share link", hint: "Anyone with the link" },
  { id: "export", label: "Export as PDF", keywords: "download print" },
  { id: "rename", label: "Rename document", shortcut: ["F2"] },
  { id: "history", label: "Version history", keywords: "revisions restore" },
  { id: "settings", label: "Open settings", shortcut: ["⌘", ","] },
];

export function CommandPaletteDemo() {
  const [open, setOpen] = useState(false);

  return (
    <div className="grid w-full place-items-center">
      <button
        type="button"
        onClick={() => setOpen(true)}
        className="mat-cap press h-9 rounded-[9px] px-3.5 text-[13px] font-medium text-ink"
      >
        Open commands
      </button>
      <CommandPalette
        open={open}
        items={commands}
        autoFocus={open}
        onDismiss={() => setOpen(false)}
        onSelect={() => setOpen(false)}
        placeholder="Type d, then o, then c"
      />
    </div>
  );
}

export default CommandPaletteDemo;

Dependencies

More by Özer

View all
  • Password Strength

    Password Strength

    1.3K
  • OTP Input

    OTP Input

    799
  • Loading Button

    Loading Button

    599
  • Progress Bar

    Progress Bar

    586
  • Reorder List

    Reorder List

    308
  • Task Steps

    Task Steps

    275
  • Hold to Confirm

    Hold to Confirm

    249
  • Reading Progress

    Reading Progress

    167