"use client";
import { ContextMenu } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
items (required) | readonly MenuAction[] | — | Items to render. |
container | Element | DocumentFragment | null | — | — |
defaultOpen | boolean | — | Initial open state when uncontrolled. |
label | string | from messages: "Context menu" | Accessible name of the menu (default from messages: "Context menu"). |
onAction | (id: string) => void | — | Called with the id of the activated command (any leaf item). |
onOpenChange | (open: boolean) => void | — | Called with the next open state. |
onValueChange | (value: string) => void | — | Called with the new value (only when it changes). |
open | boolean | — | Open state (controlled). |
portal | boolean | — | Render the menu in a portal. |
itemsrequiredreadonly MenuAction[]
Items to render.
containerElement | DocumentFragment | null
defaultOpenboolean
Initial open state when uncontrolled.
labeldefault from messages: "Context menu"string
Accessible name of the menu (default from messages: "Context menu").
onAction(id: string) => void
Called with the id of the activated command (any leaf item).
onOpenChange(open: boolean) => void
Called with the next open state.
onValueChange(value: string) => void
Called with the new value (only when it changes).
openboolean
Open state (controlled).
portalboolean
Render the menu in a portal.
Other props are passed to the root element (HTMLAttributes<HTMLDivElement>), including className, style, id and aria-* attributes.
const actions = [
{ id: "copy", label: "Copy" },
{ id: "rename", label: "Rename" },
];
<ContextMenu items={actions}>...</ContextMenu>