Context Menu

A component that displays a menu at the pointer's location, triggered by a right-click or long press. Implements the ARIA menu pattern for proper accessibility support.

Supports submenus

Supports checkable items (single or multiple) with optional indeterminate state

Focus is fully managed

Full keyboard navigation

Typeahead support

Triggers with a long press on touch devices

Architecture

so-context-menu
Slot: trigger Place your trigger here.
Slot: content
so-context-menu-content
Slot: default
so-context-menu-item
Slot: default
so-context-menu-checkbox
Slot: default
so-context-menu-radio-group
Slot: default
so-context-menu-radio-group-item
Slot: default
so-context-menu-sub
Slot: trigger You must place an so-context-menu-item here.
so-context-menu-item
Slot: default
Slot: content
so-context-menu-sub-content
Slot: default You can place the same elements as in the so-context-menu-content here.

Reference

  • Context Menu

    The root container that manages the state and behavior of the context menu system. Coordinates the interaction between triggers and contents. Handles right-click and long press events to display the menu at the appropriate position.

  • Content

    The container that holds the context menu items. Manages keyboard interactions, focus behavior and positioning relative to the trigger point. Implements proper ARIA attributes for accessibility and handles collision detection with viewport boundaries.

    • Attributes

      • aria-label
        string
        /
        default: -

        Accessible label for the context menu content when a visible label is not present.

  • Item

    An interactive menu item that can trigger an action when selected. Supports disabled states and keyboard navigation with proper ARIA attributes for accessibility.

    • Attributes

      • disabled
        boolean
        /
        default: false

        When true, prevents the user from selecting this item.

      • shortcut
        string
        /
        default: -

        Displays a keyboard shortcut hint for the menu item. This is purely informational and does not trigger the shortcut functionality.

    • Events

      • onSelect

        Event handler called when the item is clicked or has a keydown event (Space or Enter).

  • Checkbox

    A menu item that can be checked, unchecked or set to an indeterminate state. Implements proper ARIA attributes for accessibility.

    • Attributes

      • checked
        boolean
        /
        default: -

        The controlled checked state of the item. Must be used in conjunction with onCheckedChange.

      • disabled
        boolean
        /
        default: false

        When true, prevents the user from interacting with this item.

    • Events

      • onCheckedChange

        Event handler called when the checked state of the item changes.

  • Radio Group

    A container for grouping multiple radio items. Ensures that only one item in the group can be selected at a time.

    • Attributes

      • value
        string
        /
        default: -

        The value of the currently selected radio item in the group. Must be used in conjunction with onValueChange.

    • Events

      • onValueChange

        Event handler called when the selected value in the radio group changes.

  • Radio Group Item

    A selectable item within a radio group that can only be selected exclusively within its group. Implements proper ARIA attributes for accessibility.

    • Attributes

      • disabled
        boolean
        /
        default: false

        When true, prevents the user from selecting this item.

      • value
        string
        /
        default: -

        The unique value of the item. Used to identify the selected item within the radio group.

    • Events

      • onSelect

        Event handler called when the user selects the item.

  • Sub

    Container component that manages the state and behavior of a submenu. Coordinates the interaction between trigger and content components.

  • Sub Content

    The container that holds the submenu content. Manages keyboard interactions, positioning behavior and implements proper ARIA attributes for accessibility.

    • Attributes

      • aria-label
        string
        /
        default: -

        Accessible label for the submenu content when a visible label is not present.

      • aria-labelled-by
        string
        /
        default: -

        References the ID of the element that labels the submenu content.

Keyboard

  • Space

    When focus is on a menu item, activates the item or toggles its checked state.

  • Enter

    When focus is on a menu item, activates the item or toggles its checked state.

  • Moves focus to the next menu item.

  • Moves focus to the previous menu item.

  • When focus is on a context menu sub-trigger, opens its submenu.

  • When focus is on a context menu sub-trigger, closes its submenu.

made for toddle