Skip to content

Navbar ​

A title bar at the top of the page with a left / center / right three-part layout, commonly used for going back and showing a title.

Spec source: lh-ui-core/specs/navbar.json · Golden cases: cases/navbar.json (6 cases; token mappings translated into JVM unit tests, left/right taps translated into Compose UI Test)

Usage ​

The three parts are equally wide (weight(1f) each), the title is horizontally centered within the available width, and a bottom divider is drawn by default.

9:41Navbar
Back
Page title
More

HTML mock preview (Android / Compose look), not an on-device render

kotlin
LhNavbar(
  title = "页面标题",
  leftIcon = "arrow-left",
  leftText = "返回",
  rightText = "更多",
  onLeftClick = { /* go back */ },
  onRightClick = { /* more */ },
)

Left and right content ​

Text and icon can coexist (icon on the left, text on the right, gap spacing.xs); when a side has no content at all, it does not respond to taps (golden case no-left-content-no-onleftclick: that node does not even carry the clickable semantics).

9:41Navbar variants
Icon only
Text
No divider
Edit

HTML mock preview (Android / Compose look), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
titleCenter titleString?null
onLeftClickTriggered when the left area is tapped() -> Unit{}
onRightClickTriggered when the right area is tapped() -> Unit{}
leftTextLeft button text; can coexist with leftIconString?null
leftIconLeft icon name (local icon system, e.g. "arrow-left")String?null
rightTextRight button text; can coexist with rightIconString?null
rightIconRight icon nameString?null
borderedWhether to draw the bottom dividerBooleantrue
titleContentTitle content (overrides title; the spec's default slot)@Composable (() -> Unit)?null
leftContentLeft content (overrides leftText/leftIcon; the spec's left slot)@Composable (() -> Unit)?null
rightContentRight content (overrides rightText/rightIcon; the spec's right slot)@Composable (() -> Unit)?null
modifierModifierModifierModifier

When all of a side's *Content / *Text / *Icon props are empty, that side is not tappable and draws nothing.

Token reference ​

TokenUsage
navbar.heightNavbar height (44dp)
navbar.paddingHorizontalLeft/right horizontal padding (follows spacing.md)
navbar.titleFontSizeFont size of the title and both sides' text
navbar.iconSizeIcon size on both sides (follows icon.size.medium)
navbar.borderWidthBottom divider width
zIndex.stickySticky layering semantics alignment
color.background.defaultBackground color
color.text.primary / color.text.regularTitle / side text color
color.border.lighterBottom divider color

Golden case reference ​

case idAssertionLocal test
leftclick-emits-onleftclickTapping the left triggers onLeftClickLhNavbarTest.left_click_emits_onLeftClick (Compose UI Test)
rightclick-emits-onrightclickTapping the right triggers onRightClickLhNavbarTest.right_click_emits_onRightClick
no-left-content-no-onleftclickWith no left content, nothing is triggeredLhNavbarTest.no_left_content_does_not_emit_onLeftClick
title-renders-textThe title renders textLhNavbarTest.title_renders_text
bordered-uses-border-tokenThe divider consumes the border tokenLhNavbarDefaultsTest.bordered_uses_border_token + not_bordered_has_no_divider
height-uses-navbar-height-tokenThe height consumes the navbar tokenLhNavbarDefaultsTest.height_uses_navbar_height_token
bash
./gradlew :components:navbar:test                                 # JVM part
./gradlew :components:navbar:connectedAndroidTest                # Interaction part (requires a device)

lh-ui native bloodline · Android (Kotlin + Compose)