Skip to content

Input ​

A single-line text input. It supports type, size, disabled, readonly, clearable, and a maximum character count.

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

Basic usage ​

A controlled component: the host listens to ValueChange and writes the new value back to Value.

9:41Input basics
青花瓷 (ceramic blue)
Type a keyword

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

csharp
var input = new LhInput
{
    Placeholder = "Type a keyword",
};
input.ValueChange += value => { /* Controlled: write the value back to Value */ };

Sizes ​

Three sizes map to the input.height / paddingHorizontal / fontSize tokens.

9:41Input sizes
Small
Medium
Large

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

Types and states ​

Password masks the text with dots; Disabled and Readonly both suppress ValueChange, but only Disabled renders the disabled style; when focused the border takes color.focus + input.focusRingWidth.

9:41Input states
●●●●●●●●
Disabled
Focus border

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

Clear and character count ​

When Clearable is true and the value is non-empty, a clear button is shown and tapping it fires ValueChange(""); when Maxlength is exceeded, new input is truncated.

9:41Clear & count
青花瓷 (ceramic blue)
✕

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
ValueChangeValue-change callback (controlled); not fired when disabled / readonlyevent Action<string>—
FocusFired when the field gains focusevent Action—
BlurFired when the field loses focusevent Action—
ValueCurrent text value (controlled)string""
PlaceholderPlaceholder hint text; takes the color.text.placeholder tokenstring""
TypeInput type; password masks the text with dotsLhInputTypeText
SizeInput size; maps to the size tokensLhInputSizeMedium
DisabledWhether the input is disabled (no input accepted; renders the disabled style)boolfalse
ReadonlyWhether the input is read-only (focusable but accepts no input)boolfalse
ClearableWhether to show the clear buttonboolfalse
MaxlengthMaximum character count; new input is truncated when exceededint?null

LhInputSize ​

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

Token Reference ​

TokenUsage
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 unfocused border width
input.focusRingWidth / color.focusFocused border width and color
input.clearIconSizeClear-button icon size
color.background.default / color.text.primaryContainer background / text color
color.text.placeholderPlaceholder text color
color.border.baseUnfocused border color
color.disabled.{bg,text}Disabled background / text
typography.fontFamilyChinese-style serif font stack

Golden Case Reference ​

How the 8 assertions of cases/input.json map to xUnit tests (tests/LhInputTests.cs):

case idAssertionLocal test
input-emits-onvaluechangeTyping fires onValueChangeInput_Emits_OnValueChange
clearable-emits-empty-valueClearing fires onValueChange("")Clearable_Emits_Empty_Value
disabled-blocks-inputThe disabled state does not fire and renders the disabled styleDisabled_Blocks_Input
readonly-blocks-inputReadonly does not fire but renders no disabled styleReadonly_Blocks_Input
placeholder-uses-placeholder-tokenThe placeholder text takes the placeholder tokenPlaceholder_Uses_Placeholder_Token
focus-uses-focus-tokenThe focused border takes the focus tokenFocus_Uses_Focus_Token
small-size-uses-small-tokensSmall consumes the small size tokensSmall_Size_Uses_Small_Tokens
maxlength-truncates-inputInput beyond maxlength is truncatedMaxlength_Truncates_Input

Plus dark-mode suites: Dark_Colors_Come_From_Dark_Tokens / Dimensions_Are_Identical_In_Dark_Mode. Run: cd lh-ui-windows && dotnet test.

lh-ui native bloodline · Windows (C# + WinUI 3)