A dialog opened with Ctrl K (or LedgerUI.open/1) where the person types, narrows the results
by scope and jumps to a page or runs an action from the keyboard (<.command_palette>).
<.command_palette
id="palette"
scopes={[{"All", "all"}, {"Pages", "pages"}, {"Actions", "actions"}]}
items={[
%{group: "Go to", scope: "pages", label: "Orders", icon: "cart", navigate: "/orders", keys: ["G", "O"]},
%{group: "Actions", scope: "actions", label: "New order", icon: "plus", value: "new-order"}
]}
assistant={%{label: "Ask the assistant: “%{query}”", sub: "Answers with your data"}}
on_select="palette-select"
/>
<.button phx-click={LedgerUI.open("palette")}>Search</.button>The palette is a modal: LedgerUI.open/close/toggle, open, on_open and on_close work as for
LedgerUI.Components.Modal, and shortcut toggles it from anywhere. The items are filtered in the
browser by label, sub and keywords (ignoring case and accents) and by scope; with on_search
the server filters instead. Arrows move the active row, Enter presses it, Ctrl Enter opens a link
in a new tab and Esc closes. The behaviour comes from the LedgerUI.Overlay hook
(priv/static/ledger_ui/hooks/overlay.js); the ARIA is rendered by the server: the card is a
role="dialog" (aria-modal, aria-label), the input a role="combobox" with
aria-controls/aria-expanded/aria-autocomplete, the list a role="listbox" and the rows
role="option" with stable ids ("#{id}-opt-N"); the hook only moves aria-selected and
aria-activedescendant. The static previews (inline/bare) keep the design's menuitem rows.
Each item is a map with label (required) and optionally value (what on_select receives),
sub, icon, avatar (%{initials: "CD", tint: "#d97a1e"}), keys (key names on the right),
count (a badge), group, scope, keywords, style and one of navigate, patch or href.
Events (on_select: %{"id", "value", "new_tab"}, on_assistant: %{"id", "query"},
on_search: %{"id", "query", "scope"}, on_open/on_close: %{"id"}) take an event name or a
%JS{} and go to target when given.
inline renders the dialog over its own in-page scrim (a static preview, always open, no hook);
bare renders only the lu-cmd card.
Summary
Functions
Same as command_palette/1 (same attributes and slots), under the name the design vitrine uses.
Functions
Attributes
id(:string) (required)open(:boolean) - Defaults tofalse.label(:string) - Defaults to"Command palette".placeholder(:string) - Defaults to"Search or type a command".scopes(:list) - Defaults to[].scopes_label(:string) - Defaults to"Where to search".items(:list) - Defaults to[].empty(:string) - Defaults to"Nothing found".assistant(:map) - Defaults tonil.assistant_mode(:string) - Defaults to"no_match". Must be one of"no_match", or"always".on_select(:any) - Defaults tonil.on_assistant(:any) - Defaults tonil.on_search(:string) - Defaults tonil.debounce(:integer) - Defaults to200.query(:string) - Defaults to"".on_open(:any) - Defaults tonil.on_close(:any) - Defaults tonil.target(:any) - Defaults tonil.shortcut(:any) - Defaults to"Mod+k".variant(:string) - Defaults to"canvas". Must be one of"canvas", or"classic".hints(:boolean) - Defaults totrue.highlight(:string) - Defaults to"always". Must be one of"always", or"typed".hint_navigate(:string) - Defaults to"Navigate".hint_open(:string) - Defaults to"Open".hint_new_tab(:any) - Defaults to"Open in new tab".hint_close(:string) - Defaults to"Close".class(:any) - Defaults tonil.list_style(:string) - Inline style of the list (replaces the variant padding). Defaults tonil.inline(:boolean) - Static preview over an in-page scrim: always open, no hook. Defaults tofalse.bare(:boolean) - Only thelu-cmdcard, always open, no hook. Defaults tofalse.- Global attributes are accepted.
Slots
footeritem_icon
Same as command_palette/1 (same attributes and slots), under the name the design vitrine uses.
Attributes
id(:string) (required)open(:boolean) - Defaults tofalse.label(:string) - Defaults to"Command palette".placeholder(:string) - Defaults to"Search or type a command".scopes(:list) - Defaults to[].scopes_label(:string) - Defaults to"Where to search".items(:list) - Defaults to[].empty(:string) - Defaults to"Nothing found".assistant(:map) - Defaults tonil.assistant_mode(:string) - Defaults to"no_match". Must be one of"no_match", or"always".on_select(:any) - Defaults tonil.on_assistant(:any) - Defaults tonil.on_search(:string) - Defaults tonil.debounce(:integer) - Defaults to200.query(:string) - Defaults to"".on_open(:any) - Defaults tonil.on_close(:any) - Defaults tonil.target(:any) - Defaults tonil.shortcut(:any) - Defaults to"Mod+k".variant(:string) - Defaults to"canvas". Must be one of"canvas", or"classic".hints(:boolean) - Defaults totrue.highlight(:string) - Defaults to"always". Must be one of"always", or"typed".hint_navigate(:string) - Defaults to"Navigate".hint_open(:string) - Defaults to"Open".hint_new_tab(:any) - Defaults to"Open in new tab".hint_close(:string) - Defaults to"Close".class(:any) - Defaults tonil.list_style(:string) - Inline style of the list (replaces the variant padding). Defaults tonil.inline(:boolean) - Static preview over an in-page scrim: always open, no hook. Defaults tofalse.bare(:boolean) - Only thelu-cmdcard, always open, no hook. Defaults tofalse.- Global attributes are accepted.
Slots
footeritem_icon