Command Palette
Filterable command overlay. Set the commands property, then open with the button or ⌘/Ctrl + K. Arrow keys navigate, Enter runs, Esc closes.
Preview
Commands are set in a script: el.commands = [{ id, label, group, action }, …].
<button id="open-cmdk">Open command palette</button>
<esa-command-palette id="cmdk"></esa-command-palette> API
| Prop | Type | Default | Description |
|---|---|---|---|
commands | EsaCommand[] | [] | Command registry, set as a property. Each: { id, label, description?, shortcut?, group?, keywords?, disabled?, action }. |
open | boolean | false | Reflected open state. |
hotkey | boolean | true | Registers the global Cmd/Ctrl+K toggle listener. On by default. Write `="false"` to turn it off — unusually for a boolean attribute, this one reads the value. |
Methods
| Prop | Type | Default | Description |
|---|---|---|---|
show() | method | — | Opens the palette, clears the query, and focuses the input. |
close() | method | — | Closes the palette. |
toggle() | method | — | Toggles open state — also bound to Cmd/Ctrl+K. |
Selecting a command runs its action callback, then closes the palette — there is no separate event.
Accessibility
- The overlay is
role="dialog"; the results list isrole="listbox"withrole="option"items andaria-selected. - ArrowUp / ArrowDown move the active option (wrapping), Enter executes, Esc closes.
- The search input is focused automatically when the palette opens.