Context Menu

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

Right click here
My Account

Anatomy

Import all parts and piece them together.

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

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

API Reference

ContextMenu

Contains all the parts of a context menu.

Implements global attributes.

ContextMenuContent

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

Implements global attributes.

ContextMenuGroup

Contains multiple items.

Implements global attributes.

ContextMenuItem

Contains a menu item.

Custom Attributes
NameTypeDefaultDescription
disabledboolfalse

Controls whether the item appears disabled or not.

variantString""

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

Implements global and li attributes.

ContextMenuLabel

Labels groups.

Implements global attributes.

ContextMenuSeparator

Visually separates groups of menu items.

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.