Navigation Menu
A collection of links for navigating websites.
<NaviusNavigationMenu @bind-Value="_open"
class="relative flex justify-center">
<NaviusNavigationMenuList class="flex list-none items-center gap-1">
<NaviusNavigationMenuItem Value="getting-started">
<NaviusNavigationMenuTrigger
class="group ... data-[popup-open]:bg-accent">
Getting started
<svg class="group-data-[popup-open]:rotate-180">…</svg>
</NaviusNavigationMenuTrigger>
<NaviusNavigationMenuPortal>
<NaviusNavigationMenuPositioner>
<NaviusNavigationMenuPopup
class="... bg-popover text-popover-foreground shadow-md">
<NaviusNavigationMenuContent>
<NaviusNavigationMenuLink Href="#">Introduction</NaviusNavigationMenuLink>
<NaviusNavigationMenuLink Href="#">Installation</NaviusNavigationMenuLink>
</NaviusNavigationMenuContent>
</NaviusNavigationMenuPopup>
</NaviusNavigationMenuPositioner>
</NaviusNavigationMenuPortal>
</NaviusNavigationMenuItem>
<NaviusNavigationMenuItem Value="documentation">
<NaviusNavigationMenuLink Href="#">Documentation</NaviusNavigationMenuLink>
</NaviusNavigationMenuItem>
</NaviusNavigationMenuList>
</NaviusNavigationMenu>
@code { private string? _open; }Features
- Can be controlled (
@bind-Value) or uncontrolled (DefaultValue). - Full keyboard navigation with arrow-key roving across the trigger row.
- Hover opens after
OpenDelay; sweeping across triggers switches instantly while open. - Supports
horizontalandverticalorientation, plus nestedSubmenus. - Optional resizing
Viewportand anArrowthat the positioner keeps pointed at the active trigger. - Renders as a
<nav>landmark: site navigation, not amenuwidget.
Installation
Install the brain, or copy just this primitive in with the CLI.
navius add navigation-menuAnatomy
Import the parts and assemble them.
@using Navius.Primitives.Components.NavigationMenu
<NaviusNavigationMenu>
<NaviusNavigationMenuList>
<NaviusNavigationMenuItem Value="item-1">
<NaviusNavigationMenuTrigger />
<NaviusNavigationMenuPortal>
<NaviusNavigationMenuPositioner>
<NaviusNavigationMenuPopup>
<NaviusNavigationMenuArrow />
<NaviusNavigationMenuContent>
<NaviusNavigationMenuLink Href="#" />
@* Optional nested submenu. *@
<NaviusNavigationMenuSub>
<NaviusNavigationMenuList>
<NaviusNavigationMenuItem Value="sub-1">
<NaviusNavigationMenuTrigger />
<NaviusNavigationMenuContent />
</NaviusNavigationMenuItem>
</NaviusNavigationMenuList>
</NaviusNavigationMenuSub>
</NaviusNavigationMenuContent>
</NaviusNavigationMenuPopup>
</NaviusNavigationMenuPositioner>
</NaviusNavigationMenuPortal>
</NaviusNavigationMenuItem>
<NaviusNavigationMenuItem Value="item-2">
<NaviusNavigationMenuLink Href="#" />
</NaviusNavigationMenuItem>
</NaviusNavigationMenuList>
@* Optional shared resizing container. *@
<NaviusNavigationMenuViewport />
</NaviusNavigationMenu>API Reference
Root
Contains all the parts of a navigation menu and owns the open value. Renders a nav.
| Prop | Type | Default |
|---|---|---|
| Value | string? | - |
| ValueChanged | EventCallback<string?> | - |
| DefaultValue | string? | - |
| Orientation | string | "horizontal" |
| OpenDelay | int | 200 |
| CloseDelay | int | 300 |
| SkipDelayDuration | int | 300 |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
List
The top-level list of items, aligned along the edge of the active content. Renders a ul.
| Prop | Type | Default |
|---|---|---|
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
Item
A single list item holding either a Trigger + Content pair or a top-level Link. Renders an li.
| Prop | Type | Default |
|---|---|---|
| Value | string | "" |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
Trigger
The button that discloses its item's content. Renders a button.
| Prop | Type | Default |
|---|---|---|
| Disabled | bool | false |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-popup-open] | Present while the item's content is open. |
| [data-orientation] | "horizontal" | "vertical" |
| [data-disabled] | Present when disabled |
Content
The panel disclosed by a trigger. Self-anchors as a popover, or teleports into a Viewport when one is present. Renders a div.
| Prop | Type | Default |
|---|---|---|
| Side | string | "bottom" |
| Align | string | "start" |
| SideOffset | double | 8 |
| AlignOffset | double | 0 |
| Flip | bool | true |
| ForceMount | bool | false |
| OnEscapeKeyDown | EventCallback<NaviusEscapeKeyDownEventArgs> | - |
| OnPointerDownOutside | EventCallback<NaviusPointerDownOutsideEventArgs> | - |
| OnFocusOutside | EventCallback<NaviusFocusOutsideEventArgs> | - |
| OnInteractOutside | EventCallback<NaviusInteractOutsideEventArgs> | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-open] | Present while open. |
| [data-closed] | Present while closing (through the exit transition). |
| [data-orientation] | "horizontal" | "vertical" |
| [data-activation-direction] | "left" | "right" | "up" | "down" (direction of the previously active item) |
Link
A navigational anchor, used as a top-level item or inside a Content panel. Renders an a.
| Prop | Type | Default |
|---|---|---|
| Href | string? | - |
| Active | bool | false |
| OnSelect | EventCallback<NaviusSelectEventArgs> | - |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-active] | Present when Active (also sets aria-current="page") |
Arrow
A marker inside the Popup that the positioner keeps pointed at the active trigger. Replaces the former Indicator; no state tracking is needed. Renders an svg.
| Prop | Type | Default |
|---|---|---|
| Width | double | 10 |
| Height | double | 5 |
| ChildContent | RenderFragment? | - |
| Attributes | IDictionary<string, object>? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-side] | "top" | "right" | "bottom" | "left" |
Viewport
The shared resizing container that hosts the active panel. Place it outside the List; open Content teleports into it. Renders a div.
| Prop | Type | Default |
|---|---|---|
| ForceMount | bool | false |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
While open, the engine writes --navius-navigation-menu-viewport-width and --navius-navigation-menu-viewport-height (px) on the element so the container can animate to the active panel's size.
Sub
A nested submenu root, placed inside a Content panel. Owns its own open value and orientation. Renders a div.
| Prop | Type | Default |
|---|---|---|
| Value | string? | - |
| ValueChanged | EventCallback<string?> | - |
| DefaultValue | string? | - |
| Orientation | string | "vertical" |
| OpenDelay | int | 200 |
| CloseDelay | int | 300 |
| ChildContent | RenderFragment? | - |
Data attributes
| Data attribute | Values |
|---|---|
| [data-orientation] | "horizontal" | "vertical" |
Accessibility
Built as site navigation: the root is a <nav> landmark and the trigger row behaves as a single composite Tab stop with arrow-key roving, following the disclosure WAI-ARIA design pattern.
Keyboard interactions
| Key | Description |
|---|---|
| Space | When focus is on a trigger, toggles its content open or closed. |
| Enter | When focus is on a trigger, toggles its content open or closed. |
| ArrowDown | In horizontal orientation, opens the focused trigger's content and moves focus into it. |
| ArrowRight | In vertical orientation, opens the focused trigger's content and moves focus into it. In horizontal orientation, moves to the next trigger. |
| ArrowLeft | In horizontal orientation, moves focus to the previous trigger. |
| ArrowUp | In vertical orientation, moves focus to the previous trigger. |
| Home | Moves focus to the first trigger. |
| End | Moves focus to the last trigger. |
| Esc | Closes the open content and returns focus to its trigger. |
| Tab | Moves focus into the content, then out of the menu. |