Skip to content
nexubDesign System
v11.9.0

Components · Overlays

Context Menu

StableAdded v0.0.1

A menu that opens at the pointer on right-click (or long-press), built on Radix.

import { ContextMenu } from '@nexub/react';
View as Markdown

Usage

Use it for
  • Shortcuts to actions on an item: rename, duplicate, delete

Use something else for
  • The only way to reach an action: right-click is hard to discover and needs a visible alternative, such as a `DropdownMenu`

Examples

Default

Right-click here

Props

Props
PropTypeDefaultDescription
ContextMenu.Rootcompound—Holds the open state (onOpenChange, modal).
ContextMenu.Triggercompound—The area that opens the menu on right-click. Use asChild to make your element the area.
ContextMenu.Portal / Contentcompound—Renders the floating menu in a portal.
ContextMenu.Itemcompound—An action (onSelect, disabled).
ContextMenu.CheckboxItem / RadioGroup / RadioItemcompound—Toggle and single-choice items (checked, onCheckedChange; value, onValueChange).
ContextMenu.Label / Group / Separatorcompound—Section heading, grouping and divider.
ContextMenu.Sub / SubTrigger / SubContentcompound—A nested submenu.

Accessibility

ARIA roles

menumenuitemmenuitemcheckboxmenuitemradio

Keyboard

  • Shift + F10 / Menu key

    Opens the menu from the focused trigger.

  • Arrow Up / Down

    Moves between items.

  • Enter / Space

    Activates the item.

  • Escape

    Closes the menu.

On iOS & Android