Skip to content

Menu

A menu component based on BrConfigProvider global theme configuration, replicating the shadcn-vue design system. It supports multi-level nesting, shortcut annotations, and keyboard navigation. This component is primarily used to implement context menus (Right-click Context Menu).

Core Features

  • Theme Adaptation: Deeply integrated with BrConfigProvider, supporting CSS variables to configure background, foreground, radius, shadow, etc.
  • Multi-level Nesting: Supports infinite levels of nested submenus.
  • Keyboard Navigation: Fully supports Tab, Arrow Up/Down/Left/Right, Enter, Esc, and other key operations.
  • Shortcuts: Supports menu item shortcut annotations.
  • Group Separators: Supports menu groups and separators.
  • Collision Detection: Automatically adjusts the pop-up position to prevent overflowing the viewport.

Basic Usage

The simplest context menu containing a few basic operations.

Right click here
Example

Complex Menu

A complex context menu supporting groups, icons, shortcuts, and multi-level nesting, as shown in the preview.

Right-click in this area (Right click here)
Example

Nested Submenus

Support creating multi-level submenus using BrMenuSub.

Right click for Submenu
Example

Shortcut Annotations

Use the shortcut slot or property to display keyboard shortcuts.

Right click for Shortcuts
Example

Theming

BrMenu uses CSS variables from BrConfigProvider for style customization.

Configure global styles through the theme property of BrConfigProvider:

Right click (Dark Theme Menu)
Example

API Reference

BrMenu (Root)

PropertyTypeDefaultDescription
dir'ltr' | 'rtl'-Reading direction

BrMenuTrigger

PropertyTypeDefaultDescription
disabledbooleanfalseWhether the trigger is disabled

BrMenuContent

PropertyTypeDefaultDescription
loopbooleanfalseWhether keyboard navigation should loop
alignOffsetnumber-Alignment offset

BrMenuItem

PropertyTypeDefaultDescription
disabledbooleanfalseWhether disabled
insetbooleanfalseWhether to leave space for left icon
shortcutstring-Shortcut text

BrMenuSub

PropertyTypeDefaultDescription
defaultOpenbooleanfalseDefault open state
openboolean-Controlled open state