Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Command Popover with Icons and Shortcuts for Vue

An outline Open Command Menu button that opens a popover with icons on every item and shortcuts on settings.

UI library: Ark UI

An outline Open Command Menu button opens the popover. Calendar, Search Emoji, and Calculator have icons. Profile, Billing, and Settings show shortcut hints.

Keep this beside the control that opened it. Move the same list into a Dialog when it should cover the page. In Vue, Ark UI does not carry out the command.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Command anatomy: root, input, group label, list, item, shortcut

Usage

<Popover @open-change="handleOpenChange" :positioning='{ placement: "bottom-start" }'>
  <PopoverTrigger :asChild="true">
    <Button variant="outline">Open Command Menu</Button>
  </PopoverTrigger>
  <PopoverContent class="w-[400px] max-w-[calc(100vw-2rem)] p-0">
    <PopoverTitle class="sr-only">Open Command Menu</PopoverTitle>
    <Command :collection="collection" @input-value-change="handleInputValueChange">
      <CommandInput placeholder="Type a command or search..." />
      <CommandContent>
        <CommandList>
          <CommandEmpty>No results found.</CommandEmpty>
          <CommandGroup
            v-for="([group, items]) in collection.group()"
            :heading="group"
            :key="group"
          >
            <CommandItem v-for="item in items" :item="item" :key="item.value">
              <component :is="item.icon" aria-hidden="true" />
              <span>{{ item.label }}</span>
              <CommandShortcut v-if="!!item.shortcut">
                {{ item.shortcut }}
              </CommandShortcut>
            </CommandItem>
          </CommandGroup>
        </CommandList>
      </CommandContent>
    </Command>
  </PopoverContent>
</Popover>

FAQ

How is this menu anchored to the button?

The Open Command Menu button is the trigger, and the panel opens below it, lined up with its start edge. The panel is 400px wide, never wider than the screen, and has no padding, so the Command fills it. A visually hidden PopoverTitle names it. PopoverTrigger takes the button with asChild, and positioning on Popover sets placement: "bottom-start". When the popover closes, the demo clears the filter.

Which items show an icon, and which show a shortcut?

Every item has an icon. The Suggestions group holds Calendar, Search Emoji and Calculator. The Settings group holds Profile, Billing and Settings, each with a shortcut label: ⌘P, ⌘B and ⌘S.

Do those shortcut hints fire the keys?

No. CommandShortcut is a label at the end of the row, and the item's check mark stays hidden while it's there. Listen for those keys yourself if Profile, Billing or Settings should run from the keyboard.

What appears when nothing matches the search?

CommandEmpty in the list says "No results found." It shows only when the search leaves nothing.

How do I run an item from this menu in Vue?

These items don't run anything yet. Listen to @value-change on Command, which receives the chosen item's value, and keep value empty so every choice fires.

How do the keys work in this menu?

The arrow keys move through the items, Enter runs the highlighted one, and typing filters the list. Escape or a click outside closes the popover, and focus goes back to the button. CommandInput shows "Type a command or search..." until someone types. The filtering is the demo's: it builds the items with useListCollection and a contains filter, and calls filter with the input's value as it changes.

API Reference

Popover

Sets open-change="handleOpenChange", positioning="{ placement: bottom-start }" and asChild. The rest is on the Popover page.

Button

Sets variant="outline". The rest is on the Button page.

Command

Sets collection="collection", input-value-change="handleInputValueChange", placeholder="Type a command or search...", v-for="([group, items]) in collection.group()", heading="group" and key="group". The rest is on the Command page.