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.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
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.
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.
HTML mockup preview (HarmonyOS / ArkUI appearance) — not an on-device render
API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
value | Current text value (controlled) | string | '' |
placeholder | Placeholder hint text | string | '' |
type | Input type; the password type maps to ArkUI InputType.Password | LhInputType | Text |
size | Input size, maps to the size tokens | LhInputSize | Medium |
disabled | Whether disabled; ignores input and does not fire onValueChange when disabled | boolean | false |
readonly | Whether read-only; focusable but accepts no input when read-only | boolean | false |
clearable | Whether to show the clear button (when there is a value) | boolean | false |
maxlength | Maximum character count; excess input is truncated; unlimited when undefined | number? | undefined |
onValueChange | Fired when the text changes; not fired when disabled / readonly | (value: string) => void | Empty function |
onFocus | Fired when focus is gained | () => void | Empty function |
onBlur | Fired when focus is lost | () => void | Empty function |
LhInputType
| Value | Device-side landing |
|---|---|
Text | ArkUI InputType.Normal |
Password | ArkUI InputType.Password (masked display) |
LhInputSize
| Value | height | paddingHorizontal | fontSize |
|---|---|---|---|
Small | input.height.small (32vp) | input.paddingHorizontal.small (12vp) | input.fontSize.small (13) |
Medium | input.height.medium (40vp) | input.paddingHorizontal.medium (16vp) | input.fontSize.medium (14) |
Large | input.height.large (48vp) | input.paddingHorizontal.large (20vp) | input.fontSize.large (16) |
Token reference
| Token | Purpose |
|---|---|
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.borderWidth | Corner radius and border width |
input.focusRingWidth | Focus ring width |
input.clearIconSize | Clear button size (16vp) |
color.text.primary / color.text.placeholder | Input text / placeholder text color |
color.background.default / color.background.disabled | Background / disabled background color |
color.border.base / color.focus | Border color / focus color |
color.disabled.text | Disabled text color |
Golden case reference
How the 8 assertions in cases/input.json map onto hypium tests (entry/src/test/Input.test.ets):
| case id | Assertion | Local test |
|---|---|---|
input-emits-onvaluechange | Typing fires onValueChange | disabled_is_not_interactive (inverse gate assertion) |
clearable-emits-empty-value | Clearing fires the empty-value callback | clear_icon_uses_token (clear icon consumes the token) |
disabled-blocks-input | Disabled state ignores input | disabled_is_not_interactive |
readonly-blocks-input | Read-only state ignores input | readonly_still_enabled_in_appearance |
placeholder-uses-placeholder-token | Placeholder text uses the placeholder token | placeholder_uses_placeholder_token |
focus-uses-focus-token | Focused state uses the focus token | focus_uses_focus_token |
small-size-uses-small-tokens | Small consumes the small size tokens | small_size_uses_small_tokens |
maxlength-truncates-input | Input beyond the limit is truncated | maxlength_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.

