Menubar
A visually persistent menu common in desktop applications that provides quick access to a consistent set of commands.
<NaviusMenubar @bind-Value="_menu">
<NaviusMenubarMenu Value="file">
<NaviusMenubarTrigger class="... data-[popup-open]:bg-accent">File</NaviusMenubarTrigger>
<NaviusMenubarPositioner SideOffset="6">
<NaviusMenubarPopup
class="... bg-popover text-popover-foreground shadow-md">
<NaviusMenubarItem>New Tab <span class="ml-auto">⌘T</span></NaviusMenubarItem>
<NaviusMenubarItem Disabled="true">New Incognito Window</NaviusMenubarItem>
<NaviusMenubarSeparator class="-mx-1 my-1 h-px bg-border" />
<NaviusMenubarSub>
<NaviusMenubarSubTrigger>Share</NaviusMenubarSubTrigger>
<NaviusMenubarSubContent class="... bg-popover shadow-md">
<NaviusMenubarItem>Email Link</NaviusMenubarItem>
</NaviusMenubarSubContent>
</NaviusMenubarSub>
</NaviusMenubarPopup>
</NaviusMenubarPositioner>
</NaviusMenubarMenu>
<NaviusMenubarMenu Value="view">
<NaviusMenubarTrigger>View</NaviusMenubarTrigger>
<NaviusMenubarPositioner>
<NaviusMenubarPopup>
<NaviusMenubarCheckboxItem @bind-Checked="_bookmarks">
<NaviusMenubarItemIndicator>✓</NaviusMenubarItemIndicator>
Always Show Bookmarks Bar
</NaviusMenubarCheckboxItem>
<NaviusMenubarRadioGroup @bind-Value="_profile">
<NaviusMenubarRadioItem Value="benoit">
<NaviusMenubarItemIndicator>●</NaviusMenubarItemIndicator>
Benoit
</NaviusMenubarRadioItem>
</NaviusMenubarRadioGroup>
</NaviusMenubarPopup>
</NaviusMenubarPositioner>
</NaviusMenubarMenu>
</NaviusMenubar>
@code {
private string? _menu;
private bool? _bookmarks = true;
private string? _profile = "benoit";
}Features
- Can be controlled (
@bind-Value) or uncontrolled (DefaultValue); at most one menu open at a time. - Roving tabindex across the top-level triggers, with "follow focus" reopening as you arrow between menus.
- Supports submenus with configurable side/align, checkbox items, and radio groups.
- Items can be disabled, and full keyboard navigation with type-ahead is built in.
- Content self-portals to
document.bodyand is positioned by the engine, escaping overflow and stacking contexts. - Direction-aware: flips arrow keys and submenu sides in RTL.
Installation
Install the brain, or copy just this primitive in with the CLI.
navius add menubarAnatomy
Import the parts and assemble them.
@using Navius.Primitives.Components.Menubar
<NaviusMenubar>
<NaviusMenubarMenu Value="menu-1">
<NaviusMenubarTrigger />
<NaviusMenubarPositioner>
<NaviusMenubarPopup>
<NaviusMenubarLabel />
<NaviusMenubarItem />
<NaviusMenubarGroup>
<NaviusMenubarItem />
</NaviusMenubarGroup>
<NaviusMenubarCheckboxItem>
<NaviusMenubarItemIndicator />
</NaviusMenubarCheckboxItem>
<NaviusMenubarRadioGroup>
<NaviusMenubarRadioItem>
<NaviusMenubarItemIndicator />
</NaviusMenubarRadioItem>
</NaviusMenubarRadioGroup>
<NaviusMenubarSeparator />
<NaviusMenubarSub>
<NaviusMenubarSubTrigger />
<NaviusMenubarSubContent />
</NaviusMenubarSub>
<NaviusMenubarArrow />
</NaviusMenubarPopup>
</NaviusMenubarPositioner>
</NaviusMenubarMenu>
</NaviusMenubar>API Reference
Root
Contains all the parts of a menubar. Renders a div with role="menubar".
| Prop | Type | Default |
|---|---|---|
| Value | string? | - |
| ValueChanged | EventCallback<string?> | - |
| DefaultValue | string? | - |
| Orientation | string | "horizontal" |
| Dir | string? | - |
| Loop | bool | false |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
Menu
Groups a trigger and its content into one menu. Renders no DOM of its own.
| Prop | Type | Default |
|---|---|---|
| Value | string | - |
| ChildContent | RenderFragment? | - |
Trigger
Toggles the menu it belongs to. Renders a button with role="menuitem".
| Prop | Type | Default |
|---|---|---|
| Disabled | bool | false |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-popup-open] | Present while the menu is open. |
| [data-highlighted] | Present when highlighted |
| [data-disabled] | Present when disabled |
Portal
Teleports the popup into document.body (or Container). Renders no DOM of its own.
| Prop | Type | Default |
|---|---|---|
| Container | string? | document.body |
| KeepMounted | bool | false |
| ChildContent | RenderFragment? | - |
Popup
The menu surface, wrapped by the Positioner that anchors it against the trigger. Self-portals; renders a div with role="menu". The Side / Align / SideOffset / AlignOffset / AvoidCollisions / CollisionPadding / Sticky / HideWhenDetached / ArrowPadding props are set on the enclosing Positioner.
| Prop | Type | Default |
|---|---|---|
| Side | string | "bottom" |
| Align | string | "start" |
| SideOffset | double | 0 |
| AlignOffset | double | 0 |
| AvoidCollisions | bool | true |
| CollisionPadding | double? | - |
| Sticky | string? | - |
| HideWhenDetached | bool | false |
| ArrowPadding | double | 0 |
| Loop | bool | false |
| KeepMounted | bool | false |
| Modal | bool | true |
| OnEscapeKeyDown | EventCallback<NaviusEscapeKeyDownEventArgs> | - |
| OnPointerDownOutside | EventCallback<NaviusPointerDownOutsideEventArgs> | - |
| OnInteractOutside | EventCallback<NaviusInteractOutsideEventArgs> | - |
| OnCloseAutoFocus | EventCallback<NaviusCloseAutoFocusEventArgs> | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-open] | Present while open. |
| [data-closed] | Present while closing (through the exit transition). |
| [data-starting-style] | Present at the start of the open transition. |
| [data-ending-style] | Present at the start of the close transition. |
| [data-side] | "top" | "right" | "bottom" | "left" |
| [data-align] | "start" | "center" | "end" |
| [data-orientation] | "vertical" |
Arrow
An optional arrow pointing from the content at its trigger. Renders an svg.
| Prop | Type | Default |
|---|---|---|
| Width | double | 10 |
| Height | double | 5 |
Item
A selectable item inside a menu. Renders a div with role="menuitem".
| Prop | Type | Default |
|---|---|---|
| Disabled | bool | false |
| TextValue | string? | - |
| OnSelect | EventCallback<NaviusSelectEventArgs> | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-highlighted] | Present when highlighted |
| [data-disabled] | Present when disabled |
Group
Groups related items. Renders a div with role="group".
| Prop | Type | Default |
|---|---|---|
| ChildContent | RenderFragment? | - |
Label
A non-interactive label, skipped by roving focus. Renders a div.
| Prop | Type | Default |
|---|---|---|
| ChildContent | RenderFragment? | - |
CheckboxItem
An item that can be checked, like a checkbox. Renders a div with role="menuitemcheckbox".
| Prop | Type | Default |
|---|---|---|
| Checked | bool? | - |
| CheckedChanged | EventCallback<bool?> | - |
| DefaultChecked | bool? | - |
| Disabled | bool | false |
| TextValue | string? | - |
| OnSelect | EventCallback<NaviusSelectEventArgs> | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-checked] | Present when checked. |
| [data-unchecked] | Present when unchecked. |
| [data-indeterminate] | Present when in the indeterminate state. |
| [data-highlighted] | Present when highlighted |
| [data-disabled] | Present when disabled |
RadioGroup
Groups radio items so exactly one is selected. Renders a div with role="group".
| Prop | Type | Default |
|---|---|---|
| Value | string? | - |
| ValueChanged | EventCallback<string?> | - |
| DefaultValue | string? | - |
| ChildContent | RenderFragment? | - |
RadioItem
An item that can be checked within a radio group. Renders a div with role="menuitemradio".
| Prop | Type | Default |
|---|---|---|
| Value | string | - |
| Disabled | bool | false |
| TextValue | string? | - |
| OnSelect | EventCallback<NaviusSelectEventArgs> | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-checked] | Present when checked. |
| [data-unchecked] | Present when unchecked. |
| [data-highlighted] | Present when highlighted |
| [data-disabled] | Present when disabled |
ItemIndicator
Renders only when its parent checkbox/radio item is checked. Renders a span.
| Prop | Type | Default |
|---|---|---|
| ForceMount | bool | false |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-checked] | Present when checked. |
| [data-unchecked] | Present when unchecked. |
Separator
A visual divider between items. Renders a div with role="separator".
| Prop | Type | Default |
|---|---|---|
| Attributes | IDictionary<string, object>? | - |
Sub
Contains the parts of a submenu, with its own open state. Renders no DOM of its own.
| Prop | Type | Default |
|---|---|---|
| Open | bool | false |
| OpenChanged | EventCallback<bool> | - |
| DefaultOpen | bool | false |
| ChildContent | RenderFragment? | - |
SubTrigger
An item that opens a submenu. Renders a div with role="menuitem".
| Prop | Type | Default |
|---|---|---|
| Disabled | bool | false |
| TextValue | string? | - |
| Dir | string? | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-popup-open] | Present while the submenu is open. |
| [data-highlighted] | Present when highlighted |
| [data-disabled] | Present when disabled |
SubContent
The submenu surface, anchored to the SubTrigger and portaled. Renders a div with role="menu".
| Prop | Type | Default |
|---|---|---|
| Side | string | "right" |
| Align | string | "start" |
| SideOffset | double | 0 |
| AlignOffset | double | 0 |
| AvoidCollisions | bool | true |
| CollisionPadding | double? | - |
| Loop | bool | false |
| ForceMount | bool | false |
| Container | string? | document.body |
| Dir | string? | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-open] | Present while open. |
| [data-closed] | Present while closing (through the exit transition). |
| [data-side] | "top" | "right" | "bottom" | "left" |
| [data-align] | "start" | "center" | "end" |
| [data-orientation] | "vertical" |
Accessibility
Adheres to the menu & menubar WAI-ARIA design pattern.
Keyboard interactions
| Key | Description |
|---|---|
| Space | When focus is on a trigger, opens the menu. When on an item, activates it. |
| Enter | When focus is on a trigger, opens the menu. When on an item, activates it. |
| ArrowDown | When focus is on a trigger, opens the menu and moves focus to the first item. When on an item, moves to the next item. |
| ArrowUp | When focus is on a trigger, opens the menu and moves focus to the last item. When on an item, moves to the previous item. |
| ArrowRight | When focus is on a trigger, moves to the next trigger. Inside an open menu, opens a submenu or moves to the next top-level menu (flipped in RTL). |
| ArrowLeft | When focus is on a trigger, moves to the previous trigger. Inside a submenu, closes it and returns focus to the SubTrigger; otherwise moves to the previous top-level menu (flipped in RTL). |
| Home | Moves focus to the first trigger or, inside a menu, the first item. |
| End | Moves focus to the last trigger or, inside a menu, the last item. |
| Esc | Closes the open menu and returns focus to its trigger. |
| A–Z, a–z | Type-ahead: moves focus to the next item whose label starts with the typed characters. |