Skip to content

Textarea ​

A controlled multi-line input that supports row count, a character counter, and a maximum length.

Spec source: lh-ui-core/specs/textarea.json · Golden cases: cases/textarea.json (6 cases, translated into JVM unit tests + Compose UI Test)

Basic usage ​

The minimum height = rows × line height × font size; once content exceeds it, the field scrolls vertically.

9:41Textarea

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

kotlin
var value by remember { mutableStateOf("") }
LhTextarea(
  value = value,
  rows = 3,
  showCount = true,
  maxlength = 200,
  onValueChange = { value = it },
)

Character counter ​

When showCount is true, a counter is rendered in the bottom-right corner (textarea.countFontSize, color text.secondary); maxlength truncates input.

9:41Textarea counter

HTML mock preview (Android / Compose look), not an on-device render; on a real device the bottom-right corner shows a "3 / 20" counter

API ​

Props ​

PropDescriptionTypeDefault
valueControlled value (required)String—
onValueChangeValue change callback (required)(String) -> Unit—
placeholderPlaceholder textString?null
rowsRow count (determines the minimum height)Int3
disabledWhether the textarea is disabledBooleanfalse
readonlyWhether the textarea is read-onlyBooleanfalse
showCountWhether to show the character counterBooleanfalse
maxlengthMaximum length (extra input is truncated)IntInt.MAX_VALUE
lhOnFocus / lhOnBlurFocus / blur callbacks(() -> Unit)?null
modifierModifierModifierModifier

Token reference ​

TokenUsage
textarea.paddingVertical / textarea.paddingHorizontalPadding (spacing.md)
textarea.fontSizeFont size (typography.fontSize.base)
textarea.borderRadius / textarea.borderWidth / textarea.focusRingWidthCorner radius / border width / focus border width
textarea.countFontSizeCounter font size (typography.fontSize.extraSmall)
textarea.minHeightMinimum-height baseline
typography.lineHeight.primaryLine height (used to convert rows)
color.text.{primary,secondary,placeholder}Text / counter / placeholder colors
color.focus / color.border.baseFocus / default border colors
color.disabled.{bg,text,border}The three disabled colors

Golden case reference ​

case idAssertionLocal test
input-emits-onvaluechangeInput triggers onValueChangeLhTextareaTest.input_emits_onValueChange (Compose UI Test)
disabled-blocks-inputThe disabled state accepts no inputLhTextareaTest.disabled_blocks_input
showcount-renders-countThe counter renders "n / max"LhTextareaTest.showcount_renders_count
showcount-without-maxlength-renders-length-onlyWithout maxlength, only the length is renderedLhTextareaTest.showcount_without_maxlength_renders_length_only
focus-uses-focus-tokenFocus consumes the focus tokensLhTextareaDefaultsTest.focus_uses_focus_tokens
maxlength-truncates-inputInput beyond the maximum length is truncatedLhTextareaTest.maxlength_truncates_input
bash
./gradlew :components:textarea:test                            # JVM part
./gradlew :components:textarea:connectedAndroidTest           # Interaction part (requires a device)

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