Skip to content

Navbar ​

A fixed bar at the top of a page. Three sections — left, center, right — supporting text and icons.

Spec source: lh-ui-core/specs/navbar.json · Golden cases: lh-ui-core/cases/navbar.json (6 cases, translated into xUnit tests)

Basic usage ​

The elevation is zIndex.sticky; the host mounts it as the fixed top bar of the page (the first Grid row or the top of a Canvas).

9:41Navbar basics
← Back青花瓷 (ceramic blue)More

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

csharp
var navbar = new LhNavbar
{
    Title = "青花瓷 (ceramic blue)",
    LeftText = "Back",
    LeftIcon = "back",
    RightText = "More",
};
navbar.LeftClick += () => { };
navbar.RightClick += () => { };

Icons ​

LeftIcon / RightIcon take a local icon name (see the glyph table in the Icon docs); when an icon and a text are both non-empty both are shown; when a side has no content, its tap event is not fired.

9:41Navbar icons
←Icon only⋯
No side content

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

Divider ​

When Bordered is true a divider in color.border.lighter is drawn at the bottom; it is on by default.

9:41Navbar divider
With divider
Without divider

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
LeftClickFired when the left area is tapped (not fired when the left side has no content)event Action—
RightClickFired when the right area is tapped (not fired when the right side has no content)event Action—
TitleCenter titlestring""
LeftTextLeft button text; shown together with LeftIcon when both are non-emptystring""
LeftIconLeft icon name (rendered by the local icon system)string?null
RightTextRight button text; shown together with RightIcon when both are non-emptystring""
RightIconRight icon name (rendered by the local icon system)string?null
BorderedWhether to draw the bottom dividerbooltrue

Token Reference ​

TokenUsage
navbar.heightHeight
navbar.paddingHorizontalLeft and right paddings
navbar.titleFontSizeFont size of the title and both sides' texts
navbar.iconSizeIcon size on both sides
navbar.borderWidthBottom divider width
color.background.defaultBackground color
color.text.primaryTitle and side text color
color.border.lighterBottom divider color
zIndex.stickySticky elevation
spacing.xsSpacing between icon and text
typography.fontFamilyChinese-style serif font stack

Golden Case Reference ​

How the 6 assertions of cases/navbar.json map to xUnit tests (tests/LhNavbarTests.cs):

case idAssertionLocal test
title-renders-textThe title renders with the font-size tokenTitle_Renders_Text
leftclick-emits-onleftclickA left tap fires onLeftClickLeftClick_Emits_OnLeftClick
rightclick-emits-onrightclickA right tap fires onRightClickRightClick_Emits_OnRightClick
no-left-content-no-onleftclickNot fired when the left side has no contentNo_Left_Content_No_OnLeftClick
bordered-uses-border-tokenThe divider consumes the border.lighter tokenBordered_Uses_Border_Token
height-uses-navbar-height-tokenThe height consumes the navbar.height tokenHeight_Uses_Navbar_Height_Token

Plus dark-mode suites: Dark_Colors_Come_From_Dark_Tokens / Dimensions_Are_Identical_In_Dark_Mode. Run: cd lh-ui-windows && dotnet test.

lh-ui native bloodline · Windows (C# + WinUI 3)