Command palette.
Summary
Functions
Renders a command palette: a dialog with a search box and grouped,
keyboard-navigable items. Opened with the keyboard shortcut (⌘K / Ctrl+K by
default), or with SlopUI.JS.open_dialog("#id").
An item inside a command palette group. Renders a link when navigate, patch or href is set.
Functions
Renders a command palette: a dialog with a search box and grouped,
keyboard-navigable items. Opened with the keyboard shortcut (⌘K / Ctrl+K by
default), or with SlopUI.JS.open_dialog("#id").
<.command id="cmd" placeholder="Search commands…">
<:group label="Navigate">
<.command_item navigate={~p"/projects"} shortcut="G P"><.icon name="folder" /> Projects</.command_item>
</:group>
<:group label="Actions">
<.command_item phx-click="new-project" hint="Creates a blank project"><.icon name="plus" /> New project</.command_item>
</:group>
</.command>Items filter as you type. For server-side search pass on_search (an
event name); the hook pushes %{"query" => text} and you re-render the
items. Enter activates the highlighted item and the palette closes.
Attributes
id(:string) (required)placeholder(:string) - defaults to "Type a command or search…". Defaults tonil.shortcut(:string) - key combined with ⌘ / Ctrl that opens the palette; nil disables. Defaults to"k".on_search(:string) - Defaults tonil.loading(:boolean) - Defaults tofalse.empty(:string) - defaults to "No results". Defaults tonil.footer(:boolean) - show the keyboard hints footer. Defaults totrue.class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["phx-target"].
Slots
group(required) - Accepts attributes:label(:string) (required)
An item inside a command palette group. Renders a link when navigate, patch or href is set.
Attributes
hint(:string) - Defaults tonil.shortcut(:string) - space-separated keys, e.g. "⌘ N". Defaults tonil.keywords(:string) - extra words that match when filtering. Defaults tonil.disabled(:boolean) - Defaults tofalse.href(:any) - Defaults tonil.navigate(:string) - Defaults tonil.patch(:string) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)