structyl

Context Menu

stable

A menu triggered by right-click or long-press.

Basic usage

Right-click here

Examples

Rich context menu

Include labels, separators, and checkbox items.

Right-click for actions

File context menu

ContextMenu supports nested actions, checkboxes and radio groups from a right-click surface.

Right-click a file row

Features

  • Submenus, checkable items.
  • Full keyboard navigation.

Installation

bash
pnpm dlx structyl add context-menu

API Reference

ContextMenu.Root

Contains all context-menu parts.

PropTypeDefault
onOpenChange(open: boolean) => void

Called when open state changes.

modalboolean

Whether outside interaction is disabled.

true

ContextMenu.Trigger

The area that opens the menu on right-click / long-press.

PropTypeDefault
disabledboolean

Disable triggering.

false

ContextMenu.Content

The menu surface, positioned at the cursor.

PropTypeDefault

ContextMenu.Item

A selectable item.

PropTypeDefault
onSelect(event: Event) => void

Called on selection.

disabledboolean

Disable the item.

Context Menu | structyl