Skip to content

Context Menu

Show a menu of actions at the pointer when someone right-clicks.

Demos

Size
Right-click here for project actions.

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy ContextMenu.vue and index.ts into app/components/ui/context-menu/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Props

PropTypeDefaultDescription
itemsMenuItem[] | MenuItem[][]โ€”Flat or grouped menu item array.
disabledbooleanfalsePrevents opening.
dir"ltr" | "rtl""ltr"Logical keyboard direction and preferred submenu side.
closeOnSelectbooleantrueCloses after normal item selection.
radioValuesRecord<string, string>โ€”State for radio item groups.
sideOffsetnumber4Gap in px from the pointer.
longPressDelaynumber700Touch/pen hold delay. Set 0 to disable.
restoreFocusbooleantrueReturns focus after keyboard close or selection.
teleportstring | false"body"Teleport target.
uiContextMenuUiโ€”Classes for root, content, and menu parts.

Slots

SlotPropsDescription
defaultisOpen, openAt, closeContext-menu surface.
[item.slot]Depends on item typePer-item render override.
checkbox-itemitem, checkedShared checkbox item renderer.
radio-itemitem, checkedShared radio item renderer.
labelitemShared label renderer.

Events

EventPayloadDescription
open-change(open, details)Fired before open state changes.
select(item, details)Fired when a normal item is selected.
check-change(item, checked, details)Fired when a checkbox item changes.
radio-change(group, value, details)Fired when a radio item is selected.
update:radioValues(values)v-model event for radio state.

Keyboard

KeyBehavior
ArrowDown / ArrowUpMove highlighted item.
Home / EndMove to first/last enabled item.
Enter / SpaceSelect or toggle highlighted item.
ArrowRight / ArrowLeftOpen/close submenu; reversed in RTL, even after a visual collision flip.
EscapeClose the current submenu level, or the context menu when at its root.
Shift+F10 / Context Menu keyOpen at focused target.

Touch and pen users can open the menu with a long press. Moving more than 10px before delay cancels it.