Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Actions

Command <pm-command>

Command palette (⌘K / Ctrl+K): a modal search over actions and pages, grouped, fuzzy-matched, keyboard driven.

Full screen
Open command palette Ctrl K New project Invite people Toggle theme Settings Billing

This component has no props to try here.

<script type="module"> import '@prismora/css'; import '@prismora/elements/button'; import '@prismora/elements/command'; import '@prismora/elements/kbd'; </script> <pm-button variant="outline" tone="neutral" commandfor="demo-cmd" command="--toggle"> Open command palette <pm-kbd>Ctrl K</pm-kbd> </pm-button> <pm-command id="demo-cmd"> <pm-command-item value="new" group="Actions" shortcut="Ctrl N">New project</pm-command-item> <pm-command-item value="invite" group="Actions" keywords="share team">Invite people</pm-command-item> <pm-command-item value="theme" group="Actions" keywords="dark light">Toggle theme</pm-command-item> <pm-command-item value="settings" group="Pages">Settings</pm-command-item> <pm-command-item value="billing" group="Pages">Billing</pm-command-item> </pm-command>

Overview

Items come from child <pm-command-item> elements or the items property. Open with the shortcut, el.show(), or an invoker: <pm-button commandfor="cmd" command="--open">.

Server search: set src (src="/api/search?q={query}", with items-path, value-key, label-key, group-key, href-key) or the loader property (async (query, { signal }) => items, mapItem to format). Local commands still match instantly; server results follow under their own group (results-group), debounced, with loading and error (Retry) states.

Attributes

AttributeTypeDefaultDescription
openbooleanfalseWhether it is open. Set to open or close it; changes when the user opens or closes it.
placeholderstringType a command or search…Hint text shown while empty (not a replacement for label).
labelstringCommand paletteAccessible name (and visible label where the component shows one).
shortcutstringmod+kGlobal shortcut ("mod+k" by default; "mod" is ⌘ on Apple, Ctrl elsewhere). Set to "" to disable.
empty-text
prop: emptyText
stringNo resultsText shown when there is nothing to list.
srcstring—Search URL; {query} is replaced with the URL-encoded text. Response: JSON.
items-path
prop: itemsPath
string—Where the list is in the response (dotted path; empty = the response itself).
value-key
prop: valueKey
string—Item field for the value (default value, then id).
label-key
prop: labelKey
string—Item field for the label (default label, then name, then title).
group-key
prop: groupKey
string—Item field for the group heading (default: results-group).
href-key
prop: hrefKey
string—Item field for a link to open (default href, then url).
results-group
prop: resultsGroup
stringResultsGroup heading for server results without their own group.
debouncenumber200Milliseconds to wait after typing before searching the server.
min-chars
prop: minChars
number1Characters needed before searching the server.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-selectonPmSelectAn item was chosen. Cancel it to keep an item with href from opening.
pm-openonPmOpenOpened.
pm-closeonPmCloseClosed.
pm-loadonPmLoadServer results arrived.
pm-load-erroronPmLoadErrorA server search failed.

Methods

show(), hide(), toggle()

<pm-command-item>

An action in a command palette (data only, not rendered itself).

Attributes

AttributeTypeDefaultDescription
valuestring—Value reported in pm-select (defaults to the text).
groupstring—Group heading.
keywordsstring—Extra search words, space or comma separated.
shortcutstring—Shortcut hint shown on the right, e.g. "Ctrl N".
hrefstring—Navigate here when chosen.
disabledboolean—Not interactive (and not submitted, for form controls).