WlCommandPalette
Behavior
Full example
<script setup lang="ts">
import { WlButton, WlCommandPalette } from "legato-ui";
import { ref } from "vue";
const visible = ref(false);
const query = ref("");
const selected = ref("");
</script>
<template>
<div class="wl-stack" data-space="md">
<WlButton @click="visible = true">{{ "Open commands" }}</WlButton><WlCommandPalette
v-model:visible="visible"
v-model:query="query"
aria-label="Material commands"
:groups="[{
id: 'actions', label: 'Actions', showWhenEmpty: true,
items: [
{ id: 'edit', label: 'Edit', icon: 'edit' },
{ id: 'archive', label: 'Archive', icon: 'folder', disabled: true }
]
}]"
@select="selected = $event.label"
/><p v-if="selected" role="status">{{ selected }}</p>
</div>
</template>Quick actions, search and states
Two groups, keywords, disabled, local filtering, loading, empty and footer. The global shortcut is disabled in this example.
Quick actions are visible immediately; search reveals other groups.
The shortcut is disabled in this example. Enable Ctrl/Cmd+K for only one palette in the application.
Full example
<script setup lang="ts">
import { WlButton, WlCheckbox, WlCommandPalette, type WlCommandPaletteGroup } from "legato-ui";
import { ref } from "vue";
const visible = ref(false);
const query = ref("");
const loading = ref(false);
const selected = ref("");
const groups: WlCommandPaletteGroup[] = [
{ id: "quick", label: "Quick actions", showWhenEmpty: true, items: [{ id: "new", label: "New material", description: "Create a local draft", icon: "plus" }, { id: "settings", label: "Settings", icon: "settings" }] },
{ id: "materials", label: "Materials", items: [{ id: "plan", label: "Release plan", description: "Team document", keywords: ["plan", "release"], icon: "file" }, { id: "report", label: "Report", icon: "file", disabled: true }] }
];
</script>
<template>
<div class="wl-stack" data-space="lg">
<WlCheckbox v-model="loading">{{ "Show results loading" }}</WlCheckbox>
<div><WlButton @click="visible = true">{{ "Open material search" }}</WlButton></div>
<WlCommandPalette
v-model:visible="visible"
v-model:query="query"
:groups="loading ? [] : groups"
:loading="loading"
aria-label="Search example materials"
@select="selected = $event.label"
>
<template #group="{ group }"><strong>{{ group.label }}</strong></template>
<template #empty="{ query: text }">
<div class="wl-stack" data-space="sm">
<span>{{ "Nothing found for «" }}{{ text }}{{ "»." }}</span>
<div><WlButton size="sm" @click="query = ''">{{ "Clear search input" }}</WlButton></div>
</div>
</template>
<template #footer>
<p class="wl-text-small wl-text-muted">{{ "↑/↓ — select · Enter — act · Escape — close" }}</p>
</template>
</WlCommandPalette>
<p class="wl-text-small" role="status">
{{ selected
? "Selected: " + selected
: "Quick actions are visible immediately; search reveals other groups." }}
</p>
<p class="wl-text-small wl-text-muted">{{ "The shortcut is disabled in this example. Enable Ctrl/Cmd+K for only one palette in the application." }}</p>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model:visible: booleanWhether the window is open; an additional query model controls the search string.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
groups | readonly (WlCommandPaletteGroup< | [] | WlCommandPaletteGroup[] with quick links and search results. group.filter selects local or external filtering. |
placeholder | string | Not set | Uses locale.searchPlaceholder when omitted or undefined; English fallback: Search or navigate…. |
emptyText | string | Not set | Uses locale.noResults when omitted or undefined; English fallback: Nothing found. |
loadingText | string | Not set | Uses locale.searching when omitted or undefined; English fallback: Searching…. |
ariaLabel | string | Not set | Uses locale.commandPalette when omitted or undefined; English fallback: Command palette. |
filter | boolean | true | Filter items locally. |
shortcut | boolean | false | Open with Ctrl/Cmd+K. |
closeOnSelect | boolean | true | — |
loading | boolean | false | — |
disabled | boolean | false | — |
size | WlSizeSm | "md" | — |
density | WlDensity | "default" | — |
motion | boolean | Inherits WlConfig.motion | Window animation; defaults to WlConfig.motion (true). |
pt | WlPt< | Not set | Attributes and callbacks for the component's documented pass-through sections. |
Events
| Event | Payload | When emitted |
|---|---|---|
search | [query: string] | Search query changed. |
select | [item: Item, | Item selected. The application handles navigation or the action. |
open | [] | Emitted when the surface opens. |
close | [] | Emitted when the surface closes. |
update:visible | boolean | Emitted when the component requests a model change; the payload is the next value. |
update:query | string | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
group | group?(props: { group: Group }): unknown; | Group heading; scope { group }. |
item | item?(props: { item: Item; group: Group; active: boolean }): unknown; | Complete item markup; scope { item, group, active }. |
item-icon | "item-icon"?(props: { item: Item; group: Group }): unknown; | Item icon; scope { item, group }. |
empty | empty?(props: { query: string }): unknown; | Empty state; scope { query }. |
footer | footer?(props: {}): unknown; | Panel footer. |
Pass-through: pt
Sections WlCommandPalette are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-command-palette | Main element of the component. |
panel | div.wl-command-palette__panel | Inner surface containing the interactive content. |
input | input.wl-command-palette__input | Native input that receives focus and control attributes. |
list | div.wl-command-palette__list | List of available items. |
group | section.wl-command-palette__group | Group of related navigation items. |
groupLabel | div.wl-command-palette__group-label | Visible heading of a navigation group. |
item | button / a.wl-command-palette__item | One repeated item. |
itemIcon | span.wl-command-palette__item-icon | Decorative item icon wrapper. |
status | div.wl-command-palette__status | Loading or empty-results message. |
footer | div.wl-command-palette__footer | Footer area below the main content. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- AriaLabel names the dialog and search combobox; disabled items cannot be selected.
- ArrowUp/ArrowDown change the active item, Enter selects it, and Escape closes the window and restores focus.
- Visible and query are separate models. Enable the global shortcut on only one palette; loading/empty should explain search status.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| ↑ / ↓ | Open the list and move the active option, skipping disabled options. |
| Home / End, PageUp / PageDown | Move to an edge or a page of available options while the list is active. |
| Enter | Choose the active option once. |
| Escape | Close the list and keep focus at its trigger or input. |
| Text | Type to search or use typeahead where the control is not editable. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model:visible. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.