Malay Patel

Command Menu

Component 4

About

A calm ⌘K command menu: fuzzy and server search, grouped results, nested pages, recents, hotkeys and full keyboard control, with optional filter pills. Free component from uibrik (uibrik.com).

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

Code

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

Usage.tsx

"use client";

import { CommandMenu, SAMPLE_FILTERS, type CommandItem } from "@/components/ui/command-menu";

// Stands in for a server: the docs items search locally, customers come from here.
const CUSTOMERS = [
  ["Acme Corp", "Invoice #1042 overdue"],
  ["Northwind Traders", "12 open orders"],
  ["Globex Industries", "Renewal in 9 days"],
  ["Initech", "Support ticket open"],
  ["Umbrella Labs", "Trial ends Friday"],
  ["Stark Supply", "Paid in full"],
];

const FILTERS = [...SAMPLE_FILTERS, { id: "customers", label: "Customers" }];

function searchCustomers(query: string, signal: AbortSignal) {
  return new Promise<CommandItem[]>((resolve, reject) => {
    const timer = setTimeout(() => {
      const q = query.toLowerCase();
      resolve(
        CUSTOMERS.filter(([name]) => name.toLowerCase().includes(q)).map(([name, note]) => ({
          id: `customer-${name}`,
          type: "customers",
          label: name,
          description: note,
        })),
      );
    }, 450);
    signal.addEventListener("abort", () => {
      clearTimeout(timer);
      reject(new DOMException("Aborted", "AbortError"));
    });
  });
}

const props = {
  placeholder: "Search docs and components",
  shortcut: "k",
  showFilters: true,
  highlight: true,
  footer: true,
  blur: true,
  width: 580,
  hotkeys: true,
  maxRecents: 4,
};

export default function Demo() {
  return (
    <div className="flex h-screen w-full items-center justify-center px-4">
      <CommandMenu {...props} filters={FILTERS} onSearch={searchCustomers} />
    </div>
  );
}

Dependencies

More by Malay Patel

View all
  • Halftone

    Halftone

    55
  • Balloon Button

    Balloon Button

    43
  • Fold Toolbar

    Fold Toolbar

    36
  • Hold To Confirm

    Hold To Confirm

    22
  • Otp Input

    Otp Input

    17
  • Marquee

    Marquee

    12
  • Aurora

    Aurora

    11
  • Segmented Control

    Segmented Control

    8