Components

Context Menu

Right-click triggered menu positioned at the pointer.

ContextMenu uses the same item model as Menu, but opens from a contextmenu event and positions the panel at the pointer. Use it for file lists, canvases, editors, tables, and other surfaces where secondary actions belong near the clicked target.

Anatomy

  • #default: The surface that receives the right-click gesture.
  • #[item.slot]: Per-item render override when an item has a slot key.
  • #checkbox-item: Shared override for checkbox menu items.
  • #radio-item: Shared override for radio menu items.
  • #label: Shared override for label rows.

The menu panel, groups, items, separators, checkbox/radio roles, and submenu panels are generated from items.

Usage

Right-click this area

Examples

Checkbox and radio items

Context menus support the same checkbox and radio item shape as Menu. Checkbox items stay open by default because closeOnSelect only applies to normal action items.

<script setup lang="ts">
import { computed, ref } from "vue";

const showGrid = ref(true);
const radioValues = ref({ sort: "name" });

const items = computed(() => [
  { type: "checkbox", label: "Show grid", checked: showGrid.value, onUpdateChecked: (value) => (showGrid.value = value) },
  { type: "radio", label: "Name", value: "name", radioGroup: "sort" },
  { type: "radio", label: "Date", value: "date", radioGroup: "sort" },
]);
</script>

<template>
  <ContextMenu v-model:radio-values="radioValues" :items="items">
    <div>Right-click</div>
  </ContextMenu>
</template>

Programmatic open

Use the exposed openAt(x, y) method when the menu should open from a custom gesture.

<script setup lang="ts">
import { ref } from "vue";
import { ContextMenu } from "akaza-ui";

const menu = ref<InstanceType<typeof ContextMenu>>();
</script>

<template>
  <ContextMenu ref="menu" :items="items">
    <button @click="menu?.openAt(120, 160, 'custom')">Open at point</button>
  </ContextMenu>
</template>

API Reference

Props

PropTypeDefaultDescription
itemsMenuItem[] | MenuItem[][]Flat or grouped menu item array.
disabledbooleanfalsePrevents opening.
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.
uiContextMenuUiClasses for root, content, and menu parts.

Emits

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.

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.

Exposed Methods

MethodSignatureDescription
openAt(x: number, y: number, reason?, event?) => voidOpens at viewport coordinates.
close(reason?, event?) => voidCloses the menu.

UI Options

ContextMenuUi extends MenuUi.

KeyDescription
rootContext-menu wrapper.
contentFloating menu panel.
panel, group, item, checkboxItem, radioItem, separator, label, submenu, submenuTrigger, submenuContentSame as Menu UI options.

Styling Hooks

UI keyCSS classData attrs
rootakaza-context-menu-rootdata-akaza-state, data-akaza-disabled
contentakaza-context-menu-content, akaza-menu-contentdata-akaza-state, data-akaza-side, data-akaza-align, --akaza-context-menu-duration
menu partsakaza-menu-*Same as Menu.

The generated root uses display: contents, so it does not change trigger-surface layout. Use ui.content for the visible popup; override ui.root display only when a real wrapper box is intentional.

Popup entry and exit use a subtle side-aware structural transition. Override --akaza-context-menu-duration to change its 120ms duration. Reduced-motion preference shortens it automatically.

Keyboard

KeyBehavior
ArrowDown / ArrowUpMove highlighted item.
Home / EndMove to first/last enabled item.
Enter / SpaceSelect or toggle highlighted item.
ArrowRight / ArrowLeftOpen/close submenu.
EscapeClose the context menu.
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.