WlCommandPalette

Command palette: command groups, quick links and search. The application connects navigation and external requests.
Components / Composites v0.2.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

size
density
placeholder

Uses locale.searchPlaceholder when omitted or undefined; English fallback: Search or navigate….

emptyText

Uses locale.noResults when omitted or undefined; English fallback: Nothing found.

loadingText

Uses locale.searching when omitted or undefined; English fallback: Searching….

ariaLabel

Uses locale.commandPalette when omitted or undefined; English fallback: Command palette.

Filter items locally.

Open with Ctrl/Cmd+K.

Window animation; defaults to WlConfig.motion (true).

Props groups, pt, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<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.

Vue SFC · additional 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>