Search documentation

Search the documentation and open a page.

Displays a menu of actions or options when a user right-clicks a target.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/context-menu

Composition

ContextMenu ├── ContextMenuTrigger └── ContextMenuContent ├── ContextMenuLabel (optional) ├── ContextMenuGroup (optional) │ └── ContextMenuItem | ContextMenuCheckboxItem | ContextMenuRadioItem │ ├── ContextMenuItemText │ └── ContextMenuShortcut (optional) ├── ContextMenuRadioGroup (optional) ├── ContextMenuSeparator (optional) └── ContextMenuSub (optional) ├── ContextMenuSubTrigger └── ContextMenuSubContent

Examples

Chat Message

Loading...

Default

Loading...

Issue

Loading...

Photo

Loading...

API Reference

ContextMenu

PropTypeDefaultDescription
idstring | undefined—Unique identifier used to connect the component parts.
idsElementIds | undefined—Overrides generated identifiers for individual parts.
defaultHighlightedValuestring | null | undefined—Configures default highlighted value.
highlightedValuestring | null | undefined—Configures highlighted value.
onHighlightChange((details: HighlightChangeDetails) => void) | undefined—Runs when highlight changes.
onSelect((details: SelectionDetails) => void) | undefined—Runs when select changes.
anchorPointPoint | null | undefined—Configures anchor point.
loopFocusboolean | undefined—Configures loop focus.
positioningPositioningOptions | undefined—Configures floating-element placement and collision handling.
closeOnSelectboolean | undefinedtrueConfigures close on select.
openboolean | undefined—Whether the component is open when controlled.
onOpenChange((details: OpenChangeDetails) => void) | undefined—Runs when open changes.
defaultOpenboolean | undefined—Initial open state when uncontrolled.
typeaheadboolean | undefined—Configures typeahead.
compositeboolean | undefined—Configures composite.
navigate((details: NavigateDetails) => void) | null | undefined—Configures navigate.
triggerValuestring | null | undefined—Configures trigger value.
defaultTriggerValuestring | null | undefined—Configures default trigger value.
onTriggerValueChange((details: TriggerValueChangeDetails) => void) | undefined—Runs when trigger value changes.

Context, Hooks, and Types

ExportAPI
ContextMenuContextRender-prop component that exposes component state and actions.
ContextMenuRootProviderProvides an externally created API to the component tree.
useMenuCreates or accesses the component API.
useMenuContextReturns the nearest component API.