Skip to content

KCommandMenu

示例

Press Ctrl+K to open command menu

A command palette overlay with grouped, searchable items and keyboard navigation. Opens with Cmd/Ctrl+K.

Props

NameTypeDefaultDescription
openbooleanfalseWhether the command menu is visible.
groupsKCommandMenuGroup[][]Array of groups, each with a name and items array ({ id, label, action? }).
placeholderstring'Type a command or search...'Placeholder text for the search input.
theme'auto' | 'day' | 'night''auto'Theme mode. auto follows the current theme; day and night force a specific mode.

Emits

NameParametersDescription
update:openbooleanEmitted when the menu should open or close.
select{ id: string; label: string; action?: () => void; groupName: string }Emitted when an item is selected.

Slots

NameDescription
This component does not provide slots.

Basic Usage

vue
<script setup>
import { ref } from 'vue'
import { KCommandMenu } from '@kK-2004/ui-component'

const open = ref(false)
const groups = [
  {
    name: 'Actions',
    items: [
      { id: 'new', label: 'New File', action: () => console.log('new') },
      { id: 'open', label: 'Open File', action: () => console.log('open') },
    ],
  },
]
</script>

<template>
  <KCommandMenu v-model:open="open" :groups="groups" />
</template>