Skip to content
Overlays & Tooltips

Context Menu

Right-click menu with items, checkboxes and submenus.

Import

tsx
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator } from "@cronus-ui/ui";
bash
npx cronus-ui add context-menu

Examples

.cronus

The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.

PortedParity: MatchGeometry 1/1Pixel diff 0 pxLogic 1/1Parity scoreboard
default.cronus
app "audit-fixtures" {
  port 5176
}

style {
  preset aurora
  theme dark
}

component ContextMenuDefault layout:inline style:context-menu {
  label "Right click"
  text "Back"
  text "Reload"
}

page "/audit/context-menu/default" type:custom {
  use ContextMenuDefault
}

API Reference

Generated from the component's exported types.

ContextMenuProps

Extends ComponentProps<typeof ContextMenuPrimitive.Root>

Skip ContextMenuProps props table
PropTypeDefaultDescription
open
boolean—Controlled open state.
defaultOpen
boolean—Uncontrolled initial open state.
onOpenChange
(open: boolean) => void—Called when the open state changes.
children
ReactNode—Contents of the component.
modal
boolean—When true, interaction outside the surface is blocked.
dir
"ltr" | "rtl"—Reading direction. Inherits from the document when omitted.

ContextMenuTriggerProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Trigger>

Skip ContextMenuTriggerProps props table
PropTypeDefaultDescription
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuGroupProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Group>

Skip ContextMenuGroupProps props table
PropTypeDefaultDescription
children
ReactNode—Contents of the component.

ContextMenuPortalProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Portal>

Skip ContextMenuPortalProps props table
PropTypeDefaultDescription
forceMount
boolean—Keep the node mounted when closed, for exit animation.

ContextMenuSubProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Sub>

Skip ContextMenuSubProps props table
PropTypeDefaultDescription
open
boolean—Controlled open state.
defaultOpen
boolean—Uncontrolled initial open state.
onOpenChange
(open: boolean) => void—Called when the open state changes.

ContextMenuRadioGroupProps

Extends ComponentPropsWithoutRef< typeof ContextMenuPrimitive.RadioGroup >

Skip ContextMenuRadioGroupProps props table
PropTypeDefaultDescription
value
string—Controlled value.
onValueChange
(value: string) => void—Called when the value changes.

ContextMenuSubTriggerProps

Extends ComponentPropsWithoutRef< typeof ContextMenuPrimitive.SubTrigger >

Skip ContextMenuSubTriggerProps props table
PropTypeDefaultDescription
inset
boolean——
disabled
boolean—Disables pointer and keyboard interaction.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.

ContextMenuSubContentProps

Extends ComponentPropsWithoutRef< typeof ContextMenuPrimitive.SubContent >

Skip ContextMenuSubContentProps props table
PropTypeDefaultDescription
side
"top" | "right" | "bottom" | "left"—Preferred side of the trigger.
align
"start" | "center" | "end"—Alignment along the chosen side.
sideOffset
number—Distance in pixels from the trigger.
alignOffset
number—Offset along the alignment axis.
forceMount
boolean—Keep the node mounted when closed, for exit animation.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuContentProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>

Skip ContextMenuContentProps props table
PropTypeDefaultDescription
side
"top" | "right" | "bottom" | "left"—Preferred side of the trigger.
align
"start" | "center" | "end"—Alignment along the chosen side.
sideOffset
number—Distance in pixels from the trigger.
alignOffset
number—Offset along the alignment axis.
forceMount
boolean—Keep the node mounted when closed, for exit animation.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuItemProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item>

Skip ContextMenuItemProps props table
PropTypeDefaultDescription
inset
boolean——
disabled
boolean—Disables pointer and keyboard interaction.
onSelect
(event: Event) => void—Called when the item is chosen.
textValue
string—Text used for typeahead. Defaults to the item's text.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuCheckboxItemProps

Extends ComponentPropsWithoutRef< typeof ContextMenuPrimitive.CheckboxItem >

Skip ContextMenuCheckboxItemProps props table
PropTypeDefaultDescription
checked
boolean—Controlled checked state. Pair with `onCheckedChange`.
onCheckedChange
(checked: boolean) => void—Called with the next checked value whenever the control toggles.
disabled
boolean—Disables pointer and keyboard interaction.
onSelect
(event: Event) => void—Called when the item is chosen.
textValue
string—Text used for typeahead. Defaults to the item's text.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuRadioItemProps

Extends ComponentPropsWithoutRef< typeof ContextMenuPrimitive.RadioItem >

Skip ContextMenuRadioItemProps props table
PropTypeDefaultDescription
value
string—Controlled value.
disabled
boolean—Disables pointer and keyboard interaction.
onSelect
(event: Event) => void—Called when the item is chosen.
textValue
string—Text used for typeahead. Defaults to the item's text.
asChild
boolean—Render as the child element via Slot.
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuLabelProps

Extends ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label>

Skip ContextMenuLabelProps props table
PropTypeDefaultDescription
inset
boolean——
children
ReactNode—Contents of the component.
className
string—Additional class names merged onto the root.

ContextMenuSeparatorProps

Extends ComponentPropsWithoutRef< typeof ContextMenuPrimitive.Separator >

Skip ContextMenuSeparatorProps props table
PropTypeDefaultDescription
className
string—Additional class names merged onto the root.

ContextMenuShortcutProps

Extends HTMLAttributes<HTMLSpanElement>

Skip ContextMenuShortcutProps props table
PropTypeDefaultDescription
className
string—Additional class names merged onto the root.
children
ReactNode—Contents of the component.
id
string—DOM id of the root element.