Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
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
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
defaultHighlightedValue | string | null | undefined | — | Configures default highlighted value. |
highlightedValue | string | null | undefined | — | Configures highlighted value. |
onHighlightChange | ((details: HighlightChangeDetails) => void) | undefined | — | Runs when highlight changes. |
onSelect | ((details: SelectionDetails) => void) | undefined | — | Runs when select changes. |
anchorPoint | Point | null | undefined | — | Configures anchor point. |
loopFocus | boolean | undefined | — | Configures loop focus. |
positioning | PositioningOptions | undefined | — | Configures floating-element placement and collision handling. |
closeOnSelect | boolean | undefined | true | Configures close on select. |
open | boolean | undefined | — | Whether the component is open when controlled. |
onOpenChange | ((details: OpenChangeDetails) => void) | undefined | — | Runs when open changes. |
defaultOpen | boolean | undefined | — | Initial open state when uncontrolled. |
typeahead | boolean | undefined | — | Configures typeahead. |
composite | boolean | undefined | — | Configures composite. |
navigate | ((details: NavigateDetails) => void) | null | undefined | — | Configures navigate. |
triggerValue | string | null | undefined | — | Configures trigger value. |
defaultTriggerValue | string | null | undefined | — | Configures default trigger value. |
onTriggerValueChange | ((details: TriggerValueChangeDetails) => void) | undefined | — | Runs when trigger value changes. |
Context, Hooks, and Types
| Export | API |
|---|---|
ContextMenuContext | Render-prop component that exposes component state and actions. |
ContextMenuRootProvider | Provides an externally created API to the component tree. |
useMenu | Creates or accesses the component API. |
useMenuContext | Returns the nearest component API. |
Angular
React
Solid
Svelte
Vue