Select base theme

Select color scheme

Toggle dark mode

GitHub repository

Context Menu

Displays a menu to the user — such as a set of actions or functions — triggered by right click or long press.

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>
                <Button />
            </ContextMenuTrigger>
            <ContextMenuContent>
                <ContextMenuGroup>
                    <ContextMenuLabel />
                    <ContextMenuItem>
                        <ContextMenuShortcut />
                    </ContextMenuItem>
                </ContextMenuGroup>
                <ContextMenuSeparator />
                <ContextMenuSub>
                    <ContextMenuSubTrigger />
                    <ContextMenuSubContent>
                        <ContextMenuGroup>
                            <ContextMenuCheckboxGroup>
                                <ContextMenuCheckboxItem />
                            </ContextMenuCheckboxGroup>
                        </ContextMenuGroup>
                        <ContextMenuSeparator />
                        <ContextMenuGroup>
                            <ContextMenuRadioGroup>
                                <ContextMenuRadioItem />
                            </ContextMenuRadioGroup>
                        </ContextMenuGroup>
                    </ContextMenuSubContent>
                </ContextMenuSub>
            </ContextMenuContent>
        </ContextMenu>
    }
}

API Reference

ContextMenu

Contains all the parts of a context menu.

Implements global attributes.

ContextMenuCheckboxGroup

A checkbox group component for context menus.

Custom Attributes
NameTypeDefaultDescription
invalidboolfalse

A reactive signal that toggles whether all the children Checkboxes appear invalid or not.

valueVec<String>[]

A dynamic list of all the values of checked children Checkboxes.

Implements global and fieldset attributes.

ContextMenuCheckboxItem

A checkbox item for context menus.

Custom Attributes
NameTypeDefaultDescription
checkedboolfalse

A reactive signal coupled to the checkbox's checked value.

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.

ContextMenuCheckboxGroup

A checkbox group component for context menus.

Custom Attributes
NameTypeDefaultDescription
invalidboolfalse

Renders the group with invalid styling.

valueString""

A reactive signal coupled to the current selected value of the group.

Implements global and fieldset attributes.

ContextMenuContent

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

Custom Attributes
NameTypeDefaultDescription
alignString"start"

Set how to align the popover. Accepted values: "start" | "center" | "end"

sideString"bottom"

Set which side the popover opens relative to the trigger point. Accepted values: "top" | "right" | "bottom" | "left""

Implements global attributes.

ContextMenuGroup

Visually groups multiple menu items.

Implements global attributes.

ContextMenuItem

Contains a context menu item.

Custom Attributes
NameTypeDefaultDescription
as_childboolfalse

This component will render without styling.

disabledboolfalse

Controls whether the item appears disabled and is clickable.

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.

ContextMenuLabel

Labels groups of menu items.

Custom Attributes
NameTypeDefaultDescription
disabledboolfalse

Renders the label with disabled styling.

insetboolfalse

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

invalidboolfalse

Renders the label with invalid styling.

label_forString""

Use this to explicitly set the id of the labeled element.

Implements global attributes.

ContextMenuRadioItem

A radio item for context menus.

Custom Attributes
NameTypeDefaultDescription
checkedboolfalse

A reactive signal coupled to the radio's checked value.

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.

ContextMenuRadioGroup

A radio group component for context menus.

Custom Attributes
NameTypeDefaultDescription
defaultString""

Set or update the default value.

invalidboolfalse

Renders the group with invalid styling.

valueString""

A reactive signal coupled to the current selected value of the radio group.

Implements global and fieldset attributes.

ContextMenuSeparator

Visually separates groups of menu items.

Custom Attributes
NameTypeDefaultDescription
orientationString"horizontal"

Specify the orientation of the separator. Accepted values: "horizontal" | "vertical".

Implements global attributes.

ContextMenuShortcut

Displays next to the item content and indicates keyboard shortcuts.

Implements global attributes.

ContextMenuTrigger

Defines the area where the context menu can be triggered.

Implements global attributes.

ContextMenuSub

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.

ContextMenuSubContent

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

Custom Attributes
NameTypeDefaultDescription
alignString"start"

Set how to align the popover. Accepted values: "start" | "center" | "end"

sideString"bottom"

Set which side the popover opens relative to the trigger point. Accepted values: "top" | "right" | "bottom" | "left""

Implements global attributes.

ContextMenuSubTrigger

A context menu item that triggers a sub menu.

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.