Skip to content

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

Free

Keyboard Shortcuts Displayed Combobox for Vue

A command combobox that shows Copy, Paste, Cut, Undo, and Redo with their shortcuts at the end of each row.

UI library: Ark UI

Every row ends with its keys: Copy, Paste, Cut, Undo, and Redo, including the redo chord. The keys sit at the end of the row. Picking a row selects the command.

Use it in a command menu so people learn the shortcut while they pick. The keys are a Kbd, not a working shortcut. In Vue, Ark UI does not listen for those chords.

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

Combobox anatomy: control, input, trigger, content, item, item indicator

Usage

<Combobox
  :collection="collection"
  @input-value-change="handleInputValueChange"
  @value-change="handleValueChange"
  :positioning="{ getAnchorElement: () => triggerRef }"
  selectionBehavior="clear"
  :value="value"
>
  <ComboboxTrigger
    :class='cn(
      buttonVariants({ variant: "outline" }),
      "w-[250px] justify-between"
    )'
    ref="triggerRef"
  >
    {{ selected ? selected.label : "Select command..." }}
  </ComboboxTrigger>
  <ComboboxContent>
    <ComboboxInput class="w-full" placeholder="Search commands..." :showTrigger="false" />
    <ComboboxEmpty>No command found.</ComboboxEmpty>
    <ComboboxList>
      <ComboboxItem
        v-for="command in collection.items"
        class="justify-between gap-2"
        :item="command"
        :key="command.value"
      >
        {{ command.label }}<Kbd>{{ command.shortcut }}</Kbd>
      </ComboboxItem>
    </ComboboxList>
  </ComboboxContent>
</Combobox>

FAQ

How is the shortcut placed?

ComboboxItem gets justify-between gap-2, so the command name sits at the start and the Kbd at the end, before the check.

Where do the shortcuts come from?

Each command keeps its shortcut in the data as text, such as ⌘C.

Do the shortcuts work?

No, they're labels. The combobox doesn't listen for those keys. Register the shortcuts in your app if they should run the commands.

What about Windows and Linux?

The ⌘ symbol is for macOS. Show Ctrl+C and so on elsewhere, picking the text from the platform.

What does the button show?

The picked command, or Select command... before a pick.

API Reference

Combobox

Sets collection="collection", input-value-change="handleInputValueChange", value-change="handleValueChange", positioning, getAnchorElement and class. The rest is on the Combobox page.

Kbd

No extra props in this demo. The rest is on the Kbd page.