Navbar

A top bar with a brand, links and actions; the links collapse into a menu on narrow screens.

Installation

bash
shellui-native add navbar

Platforms: MAUI · Avalonia. Also installs icon, element-extensions.

Usage

Basic

Rendered with ShellUI for Blazor
<ui:Navbar Title="ShellUI Native" Icon="Sparkles" SelectedValue="docs" SelectedValueChanged="OnPageChanged">
    <ui:NavbarItem Value="docs" Text="Docs" />
    <ui:NavbarItem Value="components" Text="Components" />
    <ui:NavbarItem Value="themes" Text="Themes" />
    <ui:Navbar.Actions>
        <ui:Button Icon="Search" Size="Icon" Variant="Ghost" />
    </ui:Navbar.Actions>
</ui:Navbar>
Avalonia, running in your browser

The bar is 56px high with a border below. SelectedValue is the active item's Value; pressing an item sets it.

Collapsing

When the bar is narrower than CollapseBelow (640 by default), the links move into a menu that a button opens under the bar. Picking a link closes it. Set CollapseBelow="0" to keep the links in the bar at any width.

Your own brand

Brand takes a view that replaces the icon and title, for a logo image for example.

MAUI and Avalonia

  • On Avalonia the links and the menu button are tab stops, pressed with Enter or Space.
  • On Avalonia the links are collected in Items.

API

XAML children go to Items.

Property Type Default Description
Title string — Brand text at the start of the bar.
Icon IconName None Brand icon before the title; None for no icon.
Brand View (MAUI) · Control? (Avalonia) null A view that replaces the icon and title.
Actions View (MAUI) · Control? (Avalonia) null A view at the end of the bar (buttons, an avatar, a theme toggle).
SelectedValue string — The active item's Value. Two-way bindable.
CollapseBelow double 640 Below this width the links move into the menu; 0 never collapses.
IsMenuOpen bool false Whether the collapsed links menu is open. Two-way bindable.
Event Arguments Description
SelectedValueChanged string? User input only: setting SelectedValue from code or a binding doesn't raise it.
Property Type Default Description
Text string — Link text.
Value string — Identifies the item; becomes the bar's SelectedValue when pressed.
Icon IconName None Lucide icon from IconName; None for no icon.
Event Arguments Description
Clicked — Clicked or tapped (or Enter / Space with keyboard focus).
Method Description
Press() Picks the link in code, as a click or Enter/Space would. Avalonia only.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.