Skip to content

Input ​

Single-line text input. Supports a password type, three sizes, disabled / read-only states, a clear button, and a character limit.

Spec source: lh-ui-core/specs/input.json · Golden cases: lh-ui-core/cases/input.json (8 cases, translated into hypium tests)

Basic usage ​

value is controlled, and placeholder uses the color.text.placeholder token.

9:41Input basics

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

typescript
LhInput({
  value: this.text,
  placeholder: 'Please enter content',
  clearable: true,
  onValueChange: (value: string) => { this.text = value },
})

Focus and sizes ​

On focus, the border switches to color.focus and a focus ring of input.focusRingWidth is layered on top; the three sizes map to the input.height / paddingHorizontal / fontSize tokens.

9:41Input focus and sizes

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

States and clear ​

disabled disables input and renders a disabled style; clearable shows a clear button when there is a value, and tapping it fires onValueChange(''); when maxlength is exceeded, new input is truncated.

9:41Input states
✕

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

API ​

Props ​

PropDescriptionTypeDefault
valueCurrent text value (controlled)string''
placeholderPlaceholder hint textstring''
typeInput type; the password type maps to ArkUI InputType.PasswordLhInputTypeText
sizeInput size, maps to the size tokensLhInputSizeMedium
disabledWhether disabled; ignores input and does not fire onValueChange when disabledbooleanfalse
readonlyWhether read-only; focusable but accepts no input when read-onlybooleanfalse
clearableWhether to show the clear button (when there is a value)booleanfalse
maxlengthMaximum character count; excess input is truncated; unlimited when undefinednumber?undefined
onValueChangeFired when the text changes; not fired when disabled / readonly(value: string) => voidEmpty function
onFocusFired when focus is gained() => voidEmpty function
onBlurFired when focus is lost() => voidEmpty function

LhInputType ​

ValueDevice-side landing
TextArkUI InputType.Normal
PasswordArkUI InputType.Password (masked display)

LhInputSize ​

ValueheightpaddingHorizontalfontSize
Smallinput.height.small (32vp)input.paddingHorizontal.small (12vp)input.fontSize.small (13)
Mediuminput.height.medium (40vp)input.paddingHorizontal.medium (16vp)input.fontSize.medium (14)
Largeinput.height.large (48vp)input.paddingHorizontal.large (20vp)input.fontSize.large (16)

Token reference ​

TokenPurpose
input.height.{small,medium,large}Three heights
input.paddingHorizontal.{small,medium,large}Three horizontal paddings
input.fontSize.{small,medium,large}Three font sizes
input.borderRadius / input.borderWidthCorner radius and border width
input.focusRingWidthFocus ring width
input.clearIconSizeClear button size (16vp)
color.text.primary / color.text.placeholderInput text / placeholder text color
color.background.default / color.background.disabledBackground / disabled background color
color.border.base / color.focusBorder color / focus color
color.disabled.textDisabled text color

Golden case reference ​

How the 8 assertions in cases/input.json map onto hypium tests (entry/src/test/Input.test.ets):

case idAssertionLocal test
input-emits-onvaluechangeTyping fires onValueChangedisabled_is_not_interactive (inverse gate assertion)
clearable-emits-empty-valueClearing fires the empty-value callbackclear_icon_uses_token (clear icon consumes the token)
disabled-blocks-inputDisabled state ignores inputdisabled_is_not_interactive
readonly-blocks-inputRead-only state ignores inputreadonly_still_enabled_in_appearance
placeholder-uses-placeholder-tokenPlaceholder text uses the placeholder tokenplaceholder_uses_placeholder_token
focus-uses-focus-tokenFocused state uses the focus tokenfocus_uses_focus_token
small-size-uses-small-tokensSmall consumes the small size tokenssmall_size_uses_small_tokens
maxlength-truncates-inputInput beyond the limit is truncatedmaxlength_truncates_input

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)