Skip to content

Quick Start ​

Minimal example ​

typescript
import { LhButton, LhButtonType, LhTheme } from '@lhgb/lh-ui-harmony'

@Entry
@Component
struct Demo {
  aboutToAppear(): void {
    LhTheme.apply(false) // injects the light palette; pass true for dark
  }

  build() {
    Column() {
      LhButton({
        onClick: () => { /* handle tap */ },
        type: LhButtonType.Primary,
        text: 'Primary',
      })
    }
  }
}

LhTheme.apply(isDark) serializes the palette into AppStorage, and every Lh component consumes it automatically; if it is never called, the light palette is used as a fallback.

Types and sizes ​

typescript
// Six types
LhButton({ onClick: () => {}, text: 'Default' })                        // Default
LhButton({ onClick: () => {}, type: LhButtonType.Primary, text: 'Primary' })
LhButton({ onClick: () => {}, type: LhButtonType.Success, text: 'Success' })
LhButton({ onClick: () => {}, type: LhButtonType.Warning, text: 'Warning' })
LhButton({ onClick: () => {}, type: LhButtonType.Danger, text: 'Danger' })
LhButton({ onClick: () => {}, type: LhButtonType.Info, text: 'Info' })

// Three sizes
LhButton({ onClick: () => {}, size: LhButtonSize.Small, text: 'Small' })
LhButton({ onClick: () => {}, size: LhButtonSize.Medium, text: 'Medium' })
LhButton({ onClick: () => {}, size: LhButtonSize.Large, text: 'Large' })

States ​

typescript
// Disabled: ignores taps (intercepted by .enabled) and renders a disabled style
LhButton({ onClick: () => {}, disabled: true, text: 'Disabled' })

// Loading: shows an indicator and does not fire onClick
LhButton({ onClick: () => {}, loading: true, text: 'Loading' })

// Both present: disabled wins (golden case disabled-precedes-loading)
LhButton({ onClick: () => {}, disabled: true, loading: true, text: 'Disabled wins' })

Icon and pattern background ​

typescript
// Icon names resolve against the local icon system (SymbolGlyph mapping is LhButtonTokens.iconFor; unregistered names draw nothing)
LhButton({ onClick: () => {}, type: LhButtonType.Primary, icon: 'search', text: 'Search' })

// Chinese-style pattern background (consumes the color.decoration token)
LhButton({ onClick: () => {}, type: LhButtonType.Primary, bgPattern: true, text: 'Pattern' })

Light and dark themes ​

typescript
LhTheme.apply(true)  // switches to dark globally; every component follows on its next style resolution

Component preview ​

Native UI cannot be rendered live in a browser, so this site uses an inline static HTML phone-frame simulator to show the appearance:

9:41lh-ui-harmony

An HTML mockup preview of the HarmonyOS (ArkUI) appearance — not an on-device render. Style values are taken from a snapshot of the core tokens, identical in source and value to the device. For the true on-device look, refer to the entry demo app and device screenshots.

The simulator's dark mode follows the site: toggle the theme in the top-right corner and the colors inside the phone frame change instantly (dark tokens are precomputed by core).

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