Overlays
Layout
CommandPalette
A searchable list of commands in a dialog, opened from a button or a keyboard shortcut such as ⌘K. Use it to let people reach any action or page from the keyboard.
Install
import { CommandPalette } from 'vael-ui'Playground
lg
top
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { CommandPalette } from 'vael-ui'
const items = [
{ id: 'new-file', label: 'New File', description: 'Create a blank document' },
{ id: 'new-folder', label: 'New Folder', description: 'Group related files' },
{
id: 'open-settings',
label: 'Open Settings',
description: 'Preferences and theme',
},
]
const open = ref(false)
</script>
<template>
<CommandPalette
placeholder="Type here…"
:items="items"
v-model:open="open"
/>
</template>Motion New
CommandPalette's dialog, like Dialog's. items moves the result rows.
<CommandPalette
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | overlaypanelheadertitledescriptionbodyfootermaximizeclose | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
swapresize | 'sync' | 'wait' | boolean | Content that changes while it's open crossfades ('sync') or waits for the old view to leave ('wait'), and the box eases to its new size unless resize: false. |
items | CommandPaletteItemsMotion | The result rows: values or hooks for item, and the list's stagger. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Combobox pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| ArrowDownArrowUp | Highlights the next or previous enabled item, wrapping at the ends. |
| Enter | Selects the highlighted item and closes the palette, unless closeOnSelect is false. |
| Escape | Closes the palette, unless closeOnEsc is false. |
| TabShiftTab | Moves focus within the palette, wrapping at the ends. |
- A modal Dialog, so the rest of the page is
inert. A translated “Command palette” label names both the dialog and the search input. Focus goes to the input on open and returns to the opener on close. - The input has
role="combobox"andaria-controlspointing at arole="listbox". Items arerole="option"witharia-selected, andaria-disabledwhen disabled. Groups arerole="group", named by their headings. - Focus stays in the input;
aria-activedescendantpoints at the highlighted item. As you type, arole="status"region announces the number of results, or that there are none. shortcut, such as"mod+k", toggles the palette from anywhere on the page.