Components

Context Menu

Menu representing a set of actions, displayed at the origin of a pointer right-click or long-press.

Right-click here
<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>

API Reference

This component inherits props from the ContextMenu primitive.

Root

Contains all the parts of a context menu.

Trigger

Wraps the element that will open the context menu.

Content

The component that pops out when the context menu is open.

PropTypeDefault
size
Responsive<"1" | "2">
"2"
variant
"solid" | "soft"
"solid"
color
enum
No default value
highContrast
boolean
No default value

Label

Used to render a label. It won't be focusable using arrow keys.

Item

The component that contains the context menu items.

PropTypeDefault
color
enum
No default value
shortcut
string
No default value

Group

Used to group multiple ContextMenu.Items.

RadioGroup

Used to group multiple ContextMenu.RadioItems.

RadioItem

An item that can be controlled and rendered like a radio.

CheckboxItem

An item that can be controlled and rendered like a checkbox.

Sub

Contains all the parts of a submenu.

SubTrigger

An item that opens a submenu. Must be rendered inside ContextMenu.Sub.

SubContent

The component that pops out when a submenu is open. Must be rendered inside ContextMenu.Sub.

Examples

Size

Use the size prop to control the size.

Size oneRight-click here
Size twoRight-click here
<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>

Variant

Use the variant prop to customize the visual style of the context menu.

SolidRight-click here
SoftRight-click here
<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>

Color

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).

IndigoRight-click here
CyanRight-click here
OrangeRight-click here
CrimsonRight-click here
<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>

High-contrast

Use the highContrast prop to increase color contrast with the background.

StandardRight-click here
High-contrastRight-click here
<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>
PreviousCheckbox
NextDialog