CommandPalette
Command palette with overlay, live filtering and keyboard navigation, ideal for Cmd+K / Ctrl+K shortcuts.
CommandPalette
Design lines
vue
1<script setup>2import { ref } from 'vue'34const openRubik = ref(false)5const paletteCommands = [6 { id: 'open', label: 'Open File', description: 'Open a file' },7 { id: 'save', label: 'Save File', description: 'Save changes' },8]9function onSelect(id) {10 console.log('selected', id)11}12</script>1314<Button @click="openRubik = true">Open palette (rubik)</Button>15<CommandPalette v-model="openRubik" :commands="paletteCommands" design="rubik" @select="onSelect" />Demo
Basic (commands + modelValue)
A working palette: pass commands and bind modelValue.
vue
1<script setup lang="ts">2import { ref } from 'vue'3import { CommandPalette } from '@dowardev/herdrate-vue'45const open = ref(false)6const commands = [7 { id: 'open', label: 'Open File', description: 'Open a file' },8 { id: 'save', label: 'Save File', description: 'Save changes' },9 { id: 'close', label: 'Close', description: 'Close tab' },10]1112function onSelect(id: string) {13 console.log('selected', id)14}15</script>1617<template>18 <button @click="open = true">Open palette</button>19 <CommandPalette20 v-model="open"21 :commands="commands"22 placeholder="Type a command..."23 @select="onSelect"24 />25</template>Color (color)
Each button opens a working palette: compare the prompt (>) and highlight in both colors.
vue
1<script setup lang="ts">2import { ref } from 'vue'3import { Button, CommandPalette } from '@dowardev/herdrate-vue'45const openColorPrimary = ref(false)6const openColorSuccess = ref(false)7</script>89<template>10 <div style="display: flex; gap: 0.5rem;">11 <Button @click="openColorPrimary = true" color="primary">Open primary</Button>1213 <Button @click="openColorSuccess = true" color="success">Open success</Button>14 </div>1516 <CommandPalette v-model="openColorPrimary" :commands="commands" color="primary" @select="onSelect" />1718 <CommandPalette v-model="openColorSuccess" :commands="commands" color="success" @select="onSelect" />19</template>Props
commands
List of available commands to filter and select.
| Type | Default | Required |
|---|---|---|
Array<{id, label, description?, icon?}> | [] | ❌ |
Each command has this shape:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Unique identifier |
label | string | ✅ | Visible text |
description | string | ❌ | Optional description |
icon | string | ❌ | Icon or emoji |
modelValue
Controls opening (true) and closing (false) of the palette.
| Type | Default | Required |
|---|---|---|
boolean | false | ❌ |
color
Color of the prompt (>) and of the highlighted item.
| Type | Default | Required |
|---|---|---|
'primary' | 'secondary' | 'tertiary' | 'success' | 'warning' | 'danger' | 'light' | 'medium' | 'dark' | 'primary' | ❌ |
placeholder
Placeholder of the search input.
| Type | Default | Required |
|---|---|---|
string | 'Type a command...' | ❌ |
design
Design line (or inherit from data-design).
| Type | Default | Required |
|---|---|---|
'tuix' | 'rubik' | — (inherits from data-design) | ❌ |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue | boolean | Emitted on open/close |
select | string | Emitted when a command is selected (returns id) |
CSS Custom Properties
| Token | Default | Description |
|---|---|---|
--font-mono | "JetBrains Mono", ui-monospace, monospace | Monospace font stack for code-like content (key labels, log lines, chips). |
--accent | from theme (--ctp-latte-mauve / --ctp-mocha-mauve) | Accent color, mapped from the active semantic color. |
--bg | from theme (--ctp-latte-base / --ctp-mocha-base) | Base background of the surface. |
--bg-alt | from theme (--ctp-latte-mantle / --ctp-mocha-mantle) | Alternate background (the next layer down from the base). |
--bg-panel | from theme (--ctp-latte-surface1 / --ctp-mocha-surface1) | Background of panel-like raised surfaces (cards, accordions). |
--border | from theme (--ctp-latte-surface0 / --ctp-mocha-surface0) | Outline and divider color for surfaces. |
--text | from theme (--ctp-latte-text / --ctp-mocha-text) | Primary text color used inside the component. |
--text-muted | from theme (--ctp-latte-subtext1 / --ctp-mocha-subtext1) | Secondary text for hints, annotations and disabled state. |
--color-primary | from theme (--ctp-latte-mauve / --ctp-mocha-mauve) | Primary semantic color (mauve in Catppuccin). |
--color-secondary | from theme (--ctp-latte-lavender / --ctp-mocha-lavender) | Secondary semantic color (lavender in Catppuccin). |
--color-tertiary | from theme (--ctp-latte-blue / --ctp-mocha-blue) | Tertiary semantic color (blue in Catppuccin). |
--color-success | from theme (--ctp-latte-green / --ctp-mocha-green) | Success semantic color (green in Catppuccin). |
--color-warning | from theme (--ctp-latte-yellow / --ctp-mocha-yellow) | Warning semantic color (yellow in Catppuccin). |
--color-danger | from theme (--ctp-latte-red / --ctp-mocha-red) | Danger semantic color (red in Catppuccin). |
--color-light | from theme (--ctp-latte-surface1 / --ctp-mocha-rosewater) | Light semantic color (lighter contrast tone). |
--color-medium | from theme (--ctp-latte-overlay0 / --ctp-mocha-overlay2) | Medium semantic color (mid-tone). |
--color-dark | from theme (--ctp-latte-text / --ctp-mocha-subtext1) | Dark semantic color (high contrast text). |
--shadow | none on TUIX, elevated on rubik | Elevation shadow for raised surfaces. |
--shadow-hover | var(--shadow-hover, var(--shadow)) | Shadow on hover/active state. |
Ver Theming para la convención completa.