PXD

Command Menu

Launch a set of actions as a full-screen overlay.

Default

<script setup>
import { ref } from 'vue'

const showCommandMenu = ref(false)

const options = [
  {
    type: 'group',
    label: 'Suggestions',
    options: [{ label: 'Figma Import', value: 'figma-import' }],
  },
  {
    type: 'group',
    label: 'Commands',
    options: [
      { label: 'Import Extension', value: 'import-extension' },
      { label: 'Manage Extensions', value: 'manage-extensions' },
    ],
  },
  {
    type: 'group',
    label: 'Collaboration',
    options: [
      { label: 'Flags Explorer', value: 'flags-explorer' },
      { label: 'File Explorer', value: 'file-explorer' },
      {
        label: 'Image Explorer',
        value: 'image-explorer',
        keywords: ['image', 'explorer', 'viewer', 'file', 'assets'],
      },
    ],
  },
]
</script>

<template>
  <PButton variant="primary" @click="showCommandMenu = true"> Open Command Menu </PButton>

  <PCommandMenu v-model="showCommandMenu" :options="options" placeholder="What do you need?">
    <template #item="{ item }">
      {{ item.label }}
    </template>
  </PCommandMenu>
</template>

Props

NameTypeDefaultDescription
widthstring | number640pxWidth of the inner dialog, forwarded to PModal
model-valuebooleanfalseWhether the full-screen command menu is open
optionsListOptions-Items or group entries, fuzzy-matched against the typed keyword
virtualbooleanfalseEnable virtualized rendering for large option sets
placeholderstring``Placeholder for the filter input
close-on-select-itembooleantrueClose the menu after an item is selected
close-on-press-escapebooleantrueClose the menu when Esc is pressed
close-on-click-overlaybooleantrueClose the menu when the overlay is clicked

Events

NameTypeDescription
update:modelValue(value: boolean) => voidEmitted when the open state of the menu changes.
change(value: boolean) => voidEmitted together with update:modelValue when the open state of the menu changes.
show() => voidEmitted when the menu opens.
hide() => voidEmitted when the menu closes.

Slots

NameDescription
itemCustom item content: { item, index, group, groupIndex }
groupCustom group label: { group, index }
footerFooter slot

Source

Source