Navigation

Context Menu

Show actions at the pointer or keyboard-focused target.

Open ↗
Context Menu interaction recorded with the Blinc headless renderer
Hybrid · dark · native recording · 2×

Usage and properties

Right-click the Website redesign project for icon-labelled actions. Add or remove it from favorites; the project details and next menu update in place.

Use the installation guide to add blinc_cn and its component stylesheet. Create the fixture bindings once, and return the demo from your UI builder. Values marked Bound accept Signal/Computed sources where the API supports them; structural options configure the component at construction.

PropertyTypeUpdate modelThis example
itemsVec<ContextMenuItem>ConstructionProject actions
on_context_menuEventContextCallbackOpens at the pointer position
disabledbool or IntoReactive<bool>Boundvalues.disabled

Keyboard and interaction

While the menu is open Up and Down wrap through enabled rows, Home and End jump to the ends, Enter or Space activates, Right opens a submenu and Left returns. Escape closes and restores focus; Tab closes and moves on.

Customizing it

Add application CSS after the default component layer. These selectors are the restyling surface for this component:

  • .cn-context-menu
  • .cn-menu-item
  • .cn-context-menu-item
  • .cn-context-menu-item--has-submenu

Theme and component variables: --primary, --text-primary, --text-secondary, --surface, --border, --radius-default, --duration-fast, --ease-state.

Built-in themes

The Live theme control installs Blinc's own theme bundles, including their colours, focus rings, corner shapes and motion tokens.

pub fn theme_bundle_for(name: &str) -> blinc_theme::ThemeBundle {
    match name {
        "restrained" => blinc_theme::RestrainedTheme::bundle(),
        "expressive" => blinc_theme::ExpressiveTheme::bundle(),
        _ => blinc_theme::HybridTheme::bundle(),
    }
    .with_css(blinc_cn::cn_styles::CN_STYLES)
}

Download the default widget and component stylesheets. Sample assets and licenses are available in the asset guide.

Documentation

From the canonical component guide.

Open a context menu at the pointer's window coordinates:

let action = ctx.use_signal(String::new());

div().w(240.0).h(160.0)
    .child(text("Right-click here"))
    .on_context_menu(move |event| {
        context_menu()
            .at(event.mouse_x, event.mouse_y)
            .item("Cut", move || action.set("cut".to_string()))
            .item("Copy", move || action.set("copy".to_string()))
            .separator()
            .item("Delete", move || action.set("delete".to_string()))
            .show();
    })

on_context_menu makes the target a Tab stop. Shift+F10 or the Context Menu key opens at the focused target; right-click opens at the pointer. The menu shares the dropdown's arrow, activation and dismissal keys. The returned overlay handle can close the menu programmatically.

Add SVG icons with item_with_icon; the menu aligns each icon with its label:

context_menu().at(x, y)
    .item_with_icon("Duplicate", blinc::icons::to_svg(blinc::icons::icons::COPY, 16.0), || {})
    .item_with_icon("Share", blinc::icons::to_svg(blinc::icons::icons::SHARE_2, 16.0), || {})
    .show();

Platforms and version

The component API is available in Blinc 0.6.0. The Live example runs in a dedicated worker and requires a compatible GPU surface. Preview and Code remain available when Live cannot start. The canvas has a descriptive label; a full screen-reader DOM mirror is not provided. The gallery integration is based on revision e2e55c24e078.

Recordings and live demos use the default Hybrid theme with bundled Noto Sans. The recording uses a 560 × 320 logical viewport at twice that resolution. Live follows its container and actual display density. Source base revision · Exact build source · Artifact versions and checksums · Font license.