Navbar
Top-of-page navigation bar. A three-part layout — left / title / right — with a centered title, supporting icons and a bottom divider.
Spec source:
lh-ui-core/specs/navbar.json· Golden cases:lh-ui-core/cases/navbar.json(6 cases, translated into hypium tests)
Basic usage
title is centered, leftText / rightText sit on either side, and leftIcon / rightIcon draw icons next to the text.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
LhNavbar({
title: 'Page title',
leftText: 'Back',
leftIcon: 'back',
rightText: 'More',
onLeftClick: () => {},
onRightClick: () => {},
})Icon-only and no divider
When bordered is false, no bottom divider is drawn; either side may hold an icon only.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
title | Title (centered) | string | '' |
leftText | Left-side text | string | '' |
leftIcon | Left icon name (rendered by the local icon system) | string? | undefined |
rightText | Right-side text | string | '' |
rightIcon | Right icon name | string? | undefined |
bordered | Whether to draw the bottom divider | boolean | true |
onLeftClick | Fired when the left area is tapped; not fired when there is no left content | () => void | Empty function |
onRightClick | Fired when the right area is tapped; not fired when there is no right content | () => void | Empty function |
Token reference
| Token | Purpose |
|---|---|
navbar.height | Navigation bar height (44vp) |
navbar.paddingHorizontal | Horizontal padding (12vp) |
navbar.titleFontSize | Title font size (16) |
navbar.iconSize | Left/right icon size (20vp) |
navbar.borderWidth | Bottom divider width |
color.background.default | Navigation bar background |
color.text.primary | Title and side text color |
color.border.lighter | Bottom divider color |
typography.fontWeight.bold | Title font weight |
zIndex.sticky | Sticky elevation (fixed scenarios) |
Golden case reference
How the 6 assertions in cases/navbar.json map onto hypium tests (entry/src/test/Navbar.test.ets):
| case id | Assertion | Local test |
|---|---|---|
title-renders-text | The title renders text | title_color_uses_text_primary_token |
leftclick-emits-onleftclick | A left tap fires onLeftClick | dimensions_use_tokens |
rightclick-emits-onrightclick | A right tap fires onRightClick | dimensions_use_tokens |
no-left-content-no-onleftclick | Not fired when there is no left content | dimensions_use_tokens (content gate) |
bordered-uses-border-token | The divider consumes the border token | bordered_uses_border_token |
height-uses-navbar-height-token | The height consumes the navbar.height token | height_uses_navbar_height_token |
Plus dark-mode specifics: dark_colors_come_from_dark_tokens / dimensions_are_identical_in_dark_mode. To run: in DevEco Studio, right-click entry/src/test → Run Tests.

