Input
Accepts manually entered and validated content, with controlled / uncontrolled modes, a character counter, clearing, and auto-growing textareas.
Basic usage
Controlled input
Current value: (empty)
import { useState } from 'react'
import { LhInput } from '@lh-ui/react'
export default function Demo() {
const [value, setValue] = useState('')
return <LhInput value={value} onChange={(val) => setValue(val)} placeholder="Controlled input" />
}
Features
Clearable / character limit / password / auto-growing textarea
0/10
import { LhInput } from '@lh-ui/react'
export default function Demo() {
return (
<>
<LhInput placeholder="Clearable" clearable />
<LhInput placeholder="Character limit" maxlength={10} showWordLimit />
<LhInput placeholder="Password" type="password" />
<LhInput
placeholder="Textarea"
type="textarea"
autosize={{ minRows: 2, maxRows: 4 }}
/>
</>
)
}
Label position
labelPosition offers five positions: float / top / bottom / left / right. float (the default) is a
floating label that rises to the top-left notch on focus or once a value is entered, and does not
fall back while a value remains; top / bottom place it statically above / below; left / right keep it
inline on the same row as the control, with labelWidth for fixed-width alignment.
Five label positions
import { LhInput } from '@lh-ui/react'
export default function Demo() {
return (
<>
{/* float (default): floating label */}
<LhInput label="Username" />
{/* top / bottom: static above / below */}
<LhInput label="Top label" labelPosition="top" />
<LhInput label="Bottom label" labelPosition="bottom" />
{/* left / right: inline on the same row as the control, aligned via labelWidth */}
<LhInput label="Left label" labelPosition="left" labelWidth={80} />
<LhInput label="Right label" labelPosition="right" labelWidth={80} />
</>
)
}
Input Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| value | Controlled value | string | — | — |
| defaultValue | Uncontrolled default value | string | — | — |
| type | Native type | 'text' | 'password' | 'number' | 'email' | 'tel' | 'url' | 'search' | 'textarea' | ... | — | 'text' |
| placeholder | Placeholder | string | — | Locale pack fallback (en-US: Please enter) |
| disabled | Whether to disable | boolean | — | false |
| readonly | Whether to be read-only | boolean | — | false |
| maxlength | Maximum input length (truncated when exceeded) | number | — | — |
| showWordLimit | Whether to show the character counter | boolean | — | false |
| clearable | Whether to be clearable | boolean | — | false |
| showPassword | Password visibility toggle (renders an eye button in the suffix when type is password; a React-first feature) | boolean | — | false |
| autosize | Auto-growing textarea height | boolean | { minRows?: number; maxRows?: number } |