Context Menu

Displays a menu to the user — such as a set of actions or functions — triggered by a button.

This component uses newly available browser features

This component uses CSS Anchor Positioning which has only been widely supported since January 2026. If you're targeting older or less mainstream browsers then maybe this component isn't for you, yet.

Alternatively you can use Singlestage 0.4 which positions the component correctly but with limited flexibility for alignment, or roll your own using Singlestage CSS classes for consistent styling.

More Info
Long press hereRight click here

Basic

A simple context menu with a few actions.

Long press hereRight click here

Submenu

Use MenuSub to nest secondary actions.

Long press hereRight click here

Shortcuts

Add MenuShortcut to show keyboard hints.

Long press hereRight click here

Groups

Group related actions and separate them with dividers.

Long press hereRight click here

Icons

Combine icons with labels for quick scanning.

Long press hereRight click here

Checkboxes

Checkboxes can be used in context menus.

Long press hereRight click here

Radio

Radio buttons can be used in context menus.

Long press hereRight click here

Destructive

Use the destructive variant for irreversible actions.

Long press hereRight click here

Anatomy

Import all parts and piece them together.

use leptos::prelude::*;
use singlestage::*;

#[component]
pub fn ContextMenuAnatomy() -> impl IntoView {
    view! {
        <ContextMenu>
            <ContextMenuTrigger />
            <ContextMenuContent>
                <ContextMenuGroup>
                    <ContextMenuLabel />
                    <ContextMenuItem>
                        <ContextMenuShortcut />
                    </ContextMenuItem>
                </ContextMenuGroup>
                <ContextMenuSeparator />
                <ContextMenuSub>
                    <ContextMenuSubTrigger />
                    <ContextMenuSubContent>
                        <ContextMenuGroup>
                            <ContextMenuCheckboxItem />
                            <ContextMenuCheckboxItem />
                        </ContextMenuGroup>
                        <ContextMenuSeparator />
                        <ContextMenuGroup>
                            <ContextMenuRadioGroup>
                                <ContextMenuRadioItem />
                                <ContextMenuRadioItem />
                                <ContextMenuRadioItem />
                            </ContextMenuRadioGroup>
                        </ContextMenuGroup>
                    </ContextMenuSubContent>
                </ContextMenuSub>
            </ContextMenuContent>
        </ContextMenu>
    }
}

API Reference

CheckboxItem

A checkbox item for popover menus.

Custom Attributes
NameTypeDefaultDescription
disabledboolfalse

Controls whether the item appears disabled or not.

dismissbooltrue

Toggle whether clicking this item dismisses the parent menu.

insetboolfalse

Set whether or not this element should display inset from its normal position.

variantString""

Set the display variant of the item. Accepted values: "destructive".

Implements global and li attributes.

ContextMenu

Contains all the parts of a context menu.

Custom Attributes
NameTypeDefaultDescription
openboolfalse

Reactive signal that can remotely control the open state of the popover but is not coupled to the actual state of the popover.

Implements global attributes.

ContextMenuTrigger

Defines the area where the context menu can be triggered.

Implements global attributes.

Label

Labels groups.

Custom Attributes
NameTypeDefaultDescription
insetboolfalse

Set whether or not this element should display inset from its normal position.

Implements global attributes.

MenuContent

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

Implements global attributes.

MenuGroup

Contains multiple items.

Implements global attributes.

MenuItem

Contains a menu item.

Custom Attributes
NameTypeDefaultDescription
disabledboolfalse

Controls whether the item appears disabled or not.

dismissbooltrue

Toggle whether clicking this item dismisses the parent menu.

insetboolfalse

Set whether or not this element should display inset from its normal position.

variantString""

Set the display variant of the item. Accepted values: "destructive".

Implements global and li attributes.

MenuShortcut

Displays next to the item content and indicates keyboard shortcuts.

Implements global attributes.

ContextSubMenu

Contains all the parts of a sub menu.

Custom Attributes
NameTypeDefaultDescription
openboolfalse

Reactive signal that can remotely control the open state of the popover but is not coupled to the actual state of the popover.

Implements global attributes.

MenuSubContent

The component that pops out when the sub trigger is triggered.

Implements global attributes.

MenuSubTrigger

Defines the area where a sub menu can be triggered.

Custom Attributes
NameTypeDefaultDescription
disabledboolfalse

Controls whether the item appears disabled or not.

insetboolfalse

Set whether or not this element should display inset from its normal position.

variantString""

Set the display variant of the item. Accepted values: "destructive".

Implements global and li attributes.

RadioItem

A radio item for popover menus.

Custom Attributes
NameTypeDefaultDescription
disabledboolfalse

Controls whether the item appears disabled or not.

dismissbooltrue

Toggle whether clicking this item dismisses the parent menu.

insetboolfalse

Set whether or not this element should display inset from its normal position.

variantString""

Set the display variant of the item. Accepted values: "destructive".

Implements global and li attributes.

Separator

Visually separates groups of menu items.

Implements global attributes.