Skip to content

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.

9:41Navbar basics
Page title

HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render

typescript
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.

9:41Navbar variants
Icon only

HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
titleTitle (centered)string''
leftTextLeft-side textstring''
leftIconLeft icon name (rendered by the local icon system)string?undefined
rightTextRight-side textstring''
rightIconRight icon namestring?undefined
borderedWhether to draw the bottom dividerbooleantrue
onLeftClickFired when the left area is tapped; not fired when there is no left content() => voidEmpty function
onRightClickFired when the right area is tapped; not fired when there is no right content() => voidEmpty function

Token reference ​

TokenPurpose
navbar.heightNavigation bar height (44vp)
navbar.paddingHorizontalHorizontal padding (12vp)
navbar.titleFontSizeTitle font size (16)
navbar.iconSizeLeft/right icon size (20vp)
navbar.borderWidthBottom divider width
color.background.defaultNavigation bar background
color.text.primaryTitle and side text color
color.border.lighterBottom divider color
typography.fontWeight.boldTitle font weight
zIndex.stickySticky 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 idAssertionLocal test
title-renders-textThe title renders texttitle_color_uses_text_primary_token
leftclick-emits-onleftclickA left tap fires onLeftClickdimensions_use_tokens
rightclick-emits-onrightclickA right tap fires onRightClickdimensions_use_tokens
no-left-content-no-onleftclickNot fired when there is no left contentdimensions_use_tokens (content gate)
bordered-uses-border-tokenThe divider consumes the border tokenbordered_uses_border_token
height-uses-navbar-height-tokenThe height consumes the navbar.height tokenheight_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.

lh-ui native bloodline · HarmonyOS (ArkTS + ArkUI)