Command Palette

A Spotlight/VS Code-style command palette with keyboard navigation, fuzzy search, and AI-powered suggestions. Press Cmd+K (Mac) or Ctrl+K (Windows/Linux) to open.

Preview

Install Summary

This kit will add the following files and dependencies to your project. Download the bundle and extract it into your project root.

Component Files

FilePath
command-palette.tsxcomponents/ai-assist/command-palette/command-palette.tsx
command-group.tsxcomponents/ai-assist/command-palette/command-group.tsx
command-item.tsxcomponents/ai-assist/command-palette/command-item.tsx
types.tscomponents/ai-assist/command-palette/types.ts
index.tscomponents/ai-assist/command-palette/index.ts

Utility Files

FilePath
design-tokens.tslib/design-tokens.ts

Dependencies

Install these dependencies before using the component:

Terminal
bash
npx shadcn@latest add dialog input button
Terminal
bash
npm install @phosphor-icons/react

Installation

Download the complete bundle as a ZIP file, or copy the text bundle to your clipboard:

Component Files

The component consists of the following files:

1. command-palette.tsx

command-palette.tsx
tsx
"use client";

import { useEffect, useMemo, useState, useCallback } from "react";
import {
  Command as CommandIcon,

2. command-group.tsx

command-group.tsx
tsx
"use client";

import { CommandItem } from "./command-item";
import type { CommandItem as CommandItemType } from "./types";

3. command-item.tsx

command-item.tsx
tsx
"use client";

import { cn } from "@/lib/utils";
import type { CommandItem as CommandItemType } from "./types";

4. types.ts

types.ts
tsx
export interface CommandItem {
  id: string;
  label: string;
  description?: string;
  icon?: React.ComponentType<{ className?: string }>;

5. index.ts

index.ts
tsx
export { CommandPalette, CommandPaletteTrigger } from "./command-palette";
export type { CommandPaletteProps, CommandItem } from "./types";

Shared Utilities

This component uses shared utility functions. These are included in the bundle above:

design-tokens.ts

design-tokens.ts
tsx
// Border radius
export const radius = {
  card: "rounded-xl",
  badge: "rounded-full",
  button: "rounded-lg",

Usage

app/page.tsx
tsx
"use client";

import { CommandPalette, type CommandItem } from "@/components/ai-assist";
import { File, Settings } from "@phosphor-icons/react";

Props

PropTypeDefault
commandsCommandItem[]Required
onCommandSelect(command) => void-
placeholderstring"Search..."
emptyState{ title: string, description: string }{ title: "No results", description: "Try a different search term." }
recentCommandsstring[][]
maxRecentCommandsnumber5
showTriggerbooleantrue
triggerClassNamestring-