Back to Components

Overlay

Command

Searchable ⌘K palette. Pure Svelte — no headless dep. Mount inline (this page) or inside a Dialog for a modal palette. Keyboard nav: ↑↓ to move, ↩ to select.

Examples

Inline palette

File

Edit

View

Account

<Command
  items={[
    {value: 'open', label: 'Open file', kbd: '⌘O', group: 'File'},
    {value: 'save', label: 'Save', kbd: '⌘S', group: 'File'},
    …
  ]}
  onSelect={(v) => …}
/>

Inside a Dialog

<Button onclick={() => open = true}>Open palette</Button>
<Dialog bind:open title="Quick actions" size="md">
  <Command items={…} onSelect={…} />
</Dialog>

CommandItem type

type CommandItem<V extends string = string> = {
  value: V;
  label: string;
  hint?: string;
  kbd?: string;
  group?: string;
  icon?: Snippet;
  disabled?: boolean;
};

Props

PropTypeDefaultDescription
itemsCommandItem[]List of items with optional groups, hints, kbd shortcuts.
placeholderstring'Search…'Search input placeholder.
onSelect(value: T) => voidFires when an item is chosen via click or Enter.
autoFocusbooleantrueFocus the search input on mount.
emptyLabelstring'No results'Shown when the filter yields zero items.

Install

CLI

npx @a3tai/mittsu add command