Installation
Requirements
| Environment | Minimum version |
|---|---|
| Vue | 3.3.0+ |
| Node.js | 18+ |
@nuxt/kit | 3.0.0+ (optional — only for the /nuxt module) |
Installation
bash
npm install @macrulez/vue-command-palettePeer dependency:
bash
npm install vue@>=3.3Quick start
1. Install the plugin
ts
// main.ts
import { createApp } from 'vue'
import { VCommandPalettePlugin } from '@macrulez/vue-command-palette'
import '@macrulez/vue-command-palette/style.css'
import App from './App.vue'
const app = createApp(App)
app.use(VCommandPalettePlugin, {
hotkey: ['$mod', 'k'], // Cmd+K on macOS, Ctrl+K on Windows/Linux
colorTheme: 'system', // 'light' | 'dark' | 'system'
persistRecent: true,
maxRecent: 5,
})
app.mount('#app')2. Place CommandPalette anywhere in your component tree
vue
<script setup lang="ts">
import { CommandPalette, useRegisterGroup } from '@macrulez/vue-command-palette'
useRegisterGroup({
id: 'navigation',
label: 'Navigation',
priority: 100,
commands: [
{
id: 'go-home',
label: 'Go to Home',
icon: '🏠',
perform: () => router.push('/'),
},
{
id: 'go-settings',
label: 'Settings',
icon: '⚙️',
shortcut: ['$mod', ','],
perform: () => router.push('/settings'),
},
],
})
</script>
<template>
<RouterView />
<CommandPalette placeholder="Search commands…" :max-results="12" />
</template>Press Cmd+K / Ctrl+K to open.