Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
CMDK Command Palette Patterns

CMDK Command Palette Patterns

Master CMDK command palette patterns for Google Antigravity IDE keyboard-first interfaces

CMDKCommand PaletteKeyboardReact
by Antigravity AI
⭐0Stars
.antigravity
# CMDK Command Palette Patterns for Google Antigravity IDE

Build keyboard-first interfaces with CMDK using Google Antigravity IDE. This guide covers command menus, search patterns, and integration with React.

## Basic Command Menu

```typescript
// src/components/CommandMenu.tsx
"use client";

import { useEffect, useState, useCallback } from "react";
import { Command } from "cmdk";
import { useRouter } from "next/navigation";
import { Search, FileText, Settings, User, LogOut, Moon, Sun, Home, Folder } from "lucide-react";
import { useTheme } from "next-themes";

interface CommandItem {
  id: string;
  label: string;
  icon: React.ReactNode;
  shortcut?: string;
  action: () => void;
  group: string;
}

export function CommandMenu() {
  const [open, setOpen] = useState(false);
  const [search, setSearch] = useState("");
  const router = useRouter();
  const { setTheme, theme } = useTheme();

  useEffect(() => {
    const down = (e: KeyboardEvent) => {
      if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
        e.preventDefault();
        setOpen((open) => !open);
      }
    };
    document.addEventListener("keydown", down);
    return () => document.removeEventListener("keydown", down);
  }, []);

  const runCommand = useCallback((command: () => void) => {
    setOpen(false);
    command();
  }, []);

  const commands: CommandItem[] = [
    { id: "home", label: "Go to Home", icon: <Home className="h-4 w-4" />, action: () => router.push("/"), group: "Navigation" },
    { id: "dashboard", label: "Go to Dashboard", icon: <Folder className="h-4 w-4" />, shortcut: "G D", action: () => router.push("/dashboard"), group: "Navigation" },
    { id: "settings", label: "Open Settings", icon: <Settings className="h-4 w-4" />, shortcut: "G S", action: () => router.push("/settings"), group: "Navigation" },
    { id: "profile", label: "View Profile", icon: <User className="h-4 w-4" />, action: () => router.push("/profile"), group: "Navigation" },
    { id: "theme-light", label: "Light Mode", icon: <Sun className="h-4 w-4" />, action: () => setTheme("light"), group: "Theme" },
    { id: "theme-dark", label: "Dark Mode", icon: <Moon className="h-4 w-4" />, action: () => setTheme("dark"), group: "Theme" },
    { id: "logout", label: "Log Out", icon: <LogOut className="h-4 w-4" />, action: () => signOut(), group: "Account" },
  ];

  const groups = [...new Set(commands.map((c) => c.group))];

  return (
    <Command.Dialog
      open={open}
      onOpenChange={setOpen}
      label="Command Menu"
      className="fixed inset-0 z-50"
    >
      <div className="fixed inset-0 bg-black/50" onClick={() => setOpen(false)} />
      <div className="fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-lg bg-background rounded-lg shadow-2xl border">
        <Command.Input
          value={search}
          onValueChange={setSearch}
          placeholder="Type a command or search..."
          className="w-full px-4 py-3 border-b text-base outline-none"
        />
        <Command.List className="max-h-80 overflow-y-auto p-2">
          <Command.Empty className="py-6 text-center text-sm text-muted-foreground">
            No results found.
          </Command.Empty>

          {groups.map((group) => (
            <Command.Group key={group} heading={group} className="px-2 py-1.5 text-xs font-semibold text-muted-foreground">
              {commands
                .filter((c) => c.group === group)
                .map((command) => (
                  <Command.Item
                    key={command.id}
                    value={command.label}
                    onSelect={() => runCommand(command.action)}
                    className="flex items-center gap-2 px-2 py-1.5 rounded-sm cursor-pointer aria-selected:bg-accent"
                  >
                    {command.icon}
                    <span className="flex-1">{command.label}</span>
                    {command.shortcut && (
                      <kbd className="px-1.5 py-0.5 text-xs bg-muted rounded">{command.shortcut}</kbd>
                    )}
                  </Command.Item>
                ))}
            </Command.Group>
          ))}
        </Command.List>
      </div>
    </Command.Dialog>
  );
}
```

## Search with Results

```typescript
// src/components/SearchCommand.tsx
"use client";

import { Command } from "cmdk";
import { useState, useEffect } from "react";
import { useDebounce } from "@/hooks/useDebounce";

interface SearchResult {
  id: string;
  title: string;
  description: string;
  type: "page" | "post" | "user";
  url: string;
}

export function SearchCommand() {
  const [search, setSearch] = useState("");
  const [results, setResults] = useState<SearchResult[]>([]);
  const [loading, setLoading] = useState(false);
  const debouncedSearch = useDebounce(search, 300);

  useEffect(() => {
    if (!debouncedSearch) {
      setResults([]);
      return;
    }

    setLoading(true);
    fetch("/api/search?q=" + encodeURIComponent(debouncedSearch))
      .then((res) => res.json())
      .then((data) => setResults(data.results))
      .finally(() => setLoading(false));
  }, [debouncedSearch]);

  return (
    <Command className="rounded-lg border shadow-md">
      <Command.Input
        value={search}
        onValueChange={setSearch}
        placeholder="Search..."
        className="w-full px-4 py-3 border-b outline-none"
      />
      <Command.List className="max-h-80 overflow-y-auto p-2">
        {loading && <Command.Loading>Searching...</Command.Loading>}
        <Command.Empty>No results found.</Command.Empty>

        {results.map((result) => (
          <Command.Item
            key={result.id}
            value={result.title}
            onSelect={() => (window.location.href = result.url)}
            className="flex flex-col gap-1 px-2 py-2 rounded-sm cursor-pointer aria-selected:bg-accent"
          >
            <span className="font-medium">{result.title}</span>
            <span className="text-sm text-muted-foreground">{result.description}</span>
          </Command.Item>
        ))}
      </Command.List>
    </Command>
  );
}
```

## Best Practices for Google Antigravity IDE

When using CMDK with Google Antigravity, group commands logically. Add keyboard shortcuts for common actions. Implement search with debouncing. Use proper ARIA labels. Let Gemini 3 generate command items from your routes.

Google Antigravity excels at building command palettes with CMDK.

When to Use This Prompt

This CMDK prompt is ideal for developers working on:

  • CMDK applications requiring modern best practices and optimal performance
  • Projects that need production-ready CMDK code with proper error handling
  • Teams looking to standardize their cmdk development workflow
  • Developers wanting to learn industry-standard CMDK patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their cmdk implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the CMDK code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this CMDK prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For CMDK projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...