Context Menu

Right-click menu with items and submenus.

Right click here

Installation

npx @noarka/cli add context-menu

Usage

tsx
import {  ContextMenu,  ContextMenuContent,  ContextMenuItem,  ContextMenuSeparator,  ContextMenuTrigger,} from "@noarka/ui";
tsx
<ContextMenu>  <ContextMenuTrigger className="flex h-32 items-center justify-center rounded-xl border border-dashed text-sm text-muted-foreground">    Right click me  </ContextMenuTrigger>  <ContextMenuContent>    <ContextMenuItem>Copy</ContextMenuItem>    <ContextMenuItem>Paste</ContextMenuItem>    <ContextMenuSeparator />    <ContextMenuItem variant="destructive">Delete</ContextMenuItem>  </ContextMenuContent></ContextMenu>

Examples

With label

Head the menu with an account label.

Right click here

With shortcuts

Hint at keyboard equivalents.

Right click here

With submenu

Nest a submenu off any item trigger.

Right click here

API reference

ContextMenu

PropTypeDefault
open

Controlled open state. Use with onOpenChange.

boolean-
defaultOpen

Initially open when uncontrolled.

booleanfalse
onOpenChange

Called when the menu opens or closes.

(open: boolean) => void-
disabled

Ignore user interaction.

booleanfalse

ContextMenuTrigger

PropTypeDefault
children

The right-click area. Usually a dashed zone describing the gesture.

ReactNode-
className

Additional classes merged on the trigger area.

string-

ContextMenuContent

PropTypeDefault
side

Preferred placement side.

"top" | "right" | "bottom" | "left"-
sideOffset

Gap between cursor and panel.

number4
align

Alignment against the cursor point.

"start" | "center" | "end""start"
alignOffset

Offset along the alignment axis.

number-
render

Polymorphic render prop. Use to render a custom element instead of the default panel.

ReactElement | ((props) => ReactNode)-
className

Additional classes merged with the default panel styles.

string-

ContextMenuItem

PropTypeDefault
variant

Destructive tints the item red.

"default" | "destructive""default"
inset

Offset content to align with labeled groups.

boolean-
onSelect

Back-compat alias for onClick. The menu still closes on select unless closeOnClick is false.

(event) => void-
disabled

Disable the item.

booleanfalse
render

Polymorphic render prop.

ReactElement | ((props) => ReactNode)-
className

Additional classes merged with the default item styles.

string-

ContextMenuLabel

PropTypeDefault
inset

Offset content to align with inset items. The label renders its own group, so it works directly inside content.

boolean-
className

Additional classes merged with the default label styles.

string-

ContextMenuSeparator

PropTypeDefault
className

Additional classes merged with the default separator styles.

string-

ContextMenuShortcut

PropTypeDefault
className

Additional classes merged with the shortcut hint styles.

string-

ContextMenuSubTrigger

PropTypeDefault
inset

Offset content to align with inset items.

boolean-
disabled

Disable the submenu trigger.

booleanfalse
className

Additional classes merged with the default trigger styles.

string-