Menu representing a set of actions, displayed at the origin of a pointer right-click or long-press.
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone style={{ height: 150 }} />
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Sub>
<ContextMenu.SubTrigger>More</ContextMenu.SubTrigger>
<ContextMenu.SubContent>
<ContextMenu.Item>Move to project…</ContextMenu.Item>
<ContextMenu.Item>Move to folder…</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item>Advanced options…</ContextMenu.Item>
</ContextMenu.SubContent>
</ContextMenu.Sub>
<ContextMenu.Separator />
<ContextMenu.Item>Share</ContextMenu.Item>
<ContextMenu.Item>Add to favorites</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
This component inherits props from the ContextMenu primitive.
Contains all the parts of a context menu.
Wraps the element that will open the context menu.
The component that pops out when the context menu is open.
Used to render a label. It won't be focusable using arrow keys.
The component that contains the context menu items.
Used to group multiple ContextMenu.Item
s.
Used to group multiple ContextMenu.RadioItem
s.
An item that can be controlled and rendered like a radio.
An item that can be controlled and rendered like a checkbox.
Contains all the parts of a submenu.
An item that opens a submenu. Must be rendered inside ContextMenu.Sub
.
The component that pops out when a submenu is open. Must be rendered inside ContextMenu.Sub
.
Use the size
prop to control the size.
<Grid columns="2" gap="3">
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Size one" />
</ContextMenu.Trigger>
<ContextMenu.Content size="1">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Size two" />
</ContextMenu.Trigger>
<ContextMenu.Content size="2">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
</Grid>
Use the variant
prop to customize the visual style of the context menu.
<Grid columns="2" gap="3">
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Solid" />
</ContextMenu.Trigger>
<ContextMenu.Content variant="solid">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Soft" />
</ContextMenu.Trigger>
<ContextMenu.Content variant="soft">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
</Grid>
Use the color
prop to assign a specific color, ignoring the global theme. You can also pass color
to a specific item to override for semantic reasons (ie. destruction action).
<Grid columns="2" gap="3">
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Indigo" />
</ContextMenu.Trigger>
<ContextMenu.Content color="indigo">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Cyan" />
</ContextMenu.Trigger>
<ContextMenu.Content color="cyan">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Orange" />
</ContextMenu.Trigger>
<ContextMenu.Content color="orange">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Crimson" />
</ContextMenu.Trigger>
<ContextMenu.Content color="crimson">
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ ⌫" color="red">
Delete
</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
</Grid>
Use the highContrast
prop to increase color contrast with the background.
<Grid columns="2" gap="3">
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="Standard" />
</ContextMenu.Trigger>
<ContextMenu.Content>
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
<ContextMenu.Root>
<ContextMenu.Trigger>
<RightClickZone heading="High-contrast" />
</ContextMenu.Trigger>
<ContextMenu.Content highContrast>
<ContextMenu.Item shortcut="⌘ E">Edit</ContextMenu.Item>
<ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>
<ContextMenu.Separator />
<ContextMenu.Item shortcut="⌘ N">Archive</ContextMenu.Item>
</ContextMenu.Content>
</ContextMenu.Root>
</Grid>