Playground

Playground Guide

The playground is a production-oriented workspace for shaping command UX before wiring everything in your app.

Use it to define command architecture, test keyboard/navigation behavior live, and export starter code for React, Vue, Preact, Astro, and Core (Vanilla).

What you can do in the playground

Workspace map

Controls map: Basics

Controls map: Appearance

The generated code now includes both modes under one theme object (theme.light + theme.dark) so exports remain complete and consistent.

Controls map: Sections and commands

Controls map: Code and export panel

Export examples

import { CommandPalette } from "@cmd-kit/react";

const sections = [
  {
    id: "commands",
    title: "Commands",
    items: [{ id: "toggle-theme", title: "Toggle theme", shortcut: "mod+t" }]
  }
];

const theme = {
  light: { accentColor: "#0fa6d8", backgroundColor: "#ffffff" },
  dark: { accentColor: "#35d7ff", backgroundColor: "#0b1116" }
};

export function Demo() {
  return (
    <CommandPalette
      sections={sections}
      shortcut="mod+k"
      title="Command menu"
      messages={{
        searchPlaceholder: "Search commands...",
        noResults: "No results found.",
        closeLabel: "Close command palette"
      }}
      recents={false}
      theme={theme}
    />
  );
}
<script setup lang="ts">
import { CommandPalette } from "@cmd-kit/vue";

const sections = [{ id: "commands", title: "Commands", items: [] }];
const theme = {
  light: { accentColor: "#0fa6d8", backgroundColor: "#ffffff" },
  dark: { accentColor: "#35d7ff", backgroundColor: "#0b1116" }
};
</script>

<template>
  <CommandPalette
    :sections="sections"
    :theme="theme"
    shortcut="mod+k"
    title="Command menu"
  />
</template>
import { createCommandPalette } from "@cmd-kit/core";

const palette = createCommandPalette({
  sections: [{ id: "commands", title: "Commands", items: [] }],
  theme: {
    light: { accentColor: "#0fa6d8", backgroundColor: "#ffffff" },
    dark: { accentColor: "#35d7ff", backgroundColor: "#0b1116" }
  },
  shortcut: "mod+k",
  title: "Command menu"
});

window.addEventListener("beforeunload", () => palette.destroy());

Guided flow #1: Quick start (10 minutes)

  1. Set language and title in Basics.
  2. Create your top-level sections and 3-5 core commands.
  3. Wire item subtitles + shortcuts to improve command scanning.
  4. Tune placeholder/no-results/close copy to match product tone.
  5. Open preview and validate keyboard flow end-to-end.
  6. Export your target adapter and integrate into app code.

Guided flow #2: Dual-theme setup

  1. Switch Theme target to Light and set all core tokens.
  2. Switch to Dark and mirror the same semantic token intent.
  3. Check preview in both modes from the preview mode switch.
  4. Verify item title/subtitle/shortcut contrast and focus readability.
  5. Export code and confirm both theme.light and theme.dark are present.

Guided flow #3: Information architecture and nested flows

  1. Define high-level sections by user intent (navigation, actions, settings).
  2. Place frequent commands at the top of each section.
  3. Use nested sections only for true drill-down flows.
  4. Add keywords for commands that users might search with alternative terms.
  5. Use disabled state only for intentional, contextual commands.

Guided flow #4: Async source preparation

  1. Switch data mode to Async source.
  2. Set realistic delay to simulate your backend latency envelope.
  3. Validate loading transitions and no-results behavior.
  4. Export snippet and replace mock source with real API client.
  5. Keep payload shape aligned with section/item schema.

Pre-production checklist

FAQ

Should I ship exported code without changes?

Usually no. Treat exports as starter scaffolding and adapt architecture, naming, and styling to your codebase.

Is playground output API documentation?

No. Use adapter docs as API source of truth and use playground output as integration baseline.

Can I keep using the modal open action if I already have embedded preview?

Yes. Embedded preview is for fast visual iteration; modal open flow is for realistic interaction validation.

Why are only adapter tabs shown in export?

The panel is intentionally focused on official adapter exports to keep output practical and less noisy.

When should I move from playground to implementation?

Once command architecture, preview behavior, and dual-theme tokens are stable.