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
- model command structure before writing integration code
- preview nested navigation and active-item flow in real time
- configure light/dark tokens and check visual parity quickly
- validate copy, search placeholder, empty state, and close label
- export framework-specific starter snippets from one source of truth
Workspace map
- Live preview: embedded palette that updates from configurator state
- Configurator: accordion-based control surface with progressive disclosure
- Code panel: adapter tabs with syntax-highlighted export and copy action
- Open preview action: keeps modal palette flow available for real interaction checks
Controls map: Basics
- Language: switches configurator labels and default generated copy
- Palette title: top heading in the command dialog
- Search placeholder: input placeholder text
- Shortcut: keyboard trigger string used in generated config
- Recent items: toggle + title + limit for recents section
- Data mode: static sections or async source scaffold
- Open on load: exported default-open state
Controls map: Appearance
- Theme target (Light / Dark): choose which mode to edit
- Accent / Surface / Text: main semantic tokens
- Title / Description / Muted: typography hierarchy tokens
- Section title / Item title / Item subtitle / Shortcut: list-level token granularity
- Border / Overlay: container + backdrop behavior
- Radius: rounded corners with live visual preview
- Shadow presets: quick depth presets plus optional advanced shadow value
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
- Add / move / remove section: high-level information architecture
- Section title: visible command group label
- Add / move / remove item: command-level ordering and maintenance
- Item fields: title, icon, subtitle, shortcut, href, keywords, disabled
- Nested commands: drill-down groups under an item for multi-step flows
- Nested section controls: add/move/remove nested sections and nested items
Controls map: Code and export panel
- Adapter tabs: React, Vue, Preact, Astro, Core (Vanilla)
- Copy action: copies current snippet with success/error feedback
- Expand snippet: partial-collapse editor view with animated expand/collapse
- Live sync: snippets update automatically from configurator state
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)
- Set language and title in Basics.
- Create your top-level sections and 3-5 core commands.
- Wire item subtitles + shortcuts to improve command scanning.
- Tune placeholder/no-results/close copy to match product tone.
- Open preview and validate keyboard flow end-to-end.
- Export your target adapter and integrate into app code.
Guided flow #2: Dual-theme setup
- Switch Theme target to Light and set all core tokens.
- Switch to Dark and mirror the same semantic token intent.
- Check preview in both modes from the preview mode switch.
- Verify item title/subtitle/shortcut contrast and focus readability.
- Export code and confirm both
theme.lightandtheme.darkare present.
Guided flow #3: Information architecture and nested flows
- Define high-level sections by user intent (navigation, actions, settings).
- Place frequent commands at the top of each section.
- Use nested sections only for true drill-down flows.
- Add keywords for commands that users might search with alternative terms.
- Use disabled state only for intentional, contextual commands.
Guided flow #4: Async source preparation
- Switch data mode to Async source.
- Set realistic delay to simulate your backend latency envelope.
- Validate loading transitions and no-results behavior.
- Export snippet and replace mock source with real API client.
- Keep payload shape aligned with section/item schema.
Pre-production checklist
- keyboard open/close and arrow navigation validated
- nested back-navigation and breadcrumbs validated
- light/dark parity validated across dialog, items, and shortcuts
- copy/messages localized by app i18n layer
- generated snippet normalized to project lint/style rules
- real async/error states validated in app runtime
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.