InputTag
Enter multiple items as tags: Enter / comma / space commits a tag, Backspace on empty input removes the last one.
Basic usage
Basic usage
水墨留白
Current tags:水墨、留白
只读
禁用
import { LhInputTag } from '@lh-ui/react'
export default function Demo() {
return (
<LhInputTag
defaultValue={['Ink wash', 'Blank space']}
placeholder="Type and press Enter to create a tag"
/>
)
}
InputTag Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| value / defaultValue | Tag list (controlled / uncontrolled) | string[] | — | — |
| onChange | Tag list changed | (value: string[]) => void | — | — |
| onAdd | A single tag committed | (tag: string) => void | — | — |
| onRemove | A single tag removed | (tag: string) => void | — | — |
| trigger | Key that commits a tag | LhInputTagTrigger | 'enter' | 'space' | 'comma' | 'enter' |
| placeholder | Placeholder (shown only when there are no tags) | string | — | '' |
| max | Tag limit (non-positive = unlimited) | number | — | 0 |
| allowDuplicate | Allow duplicate tags | boolean | — | false |
| readonly | Read-only (no tags created, delete keys ignored) | boolean | — | false |
| disabled | Disabled | boolean | — | false |
| ariaLabel | Accessible name (falls back to locale pack inputTag.label) | string | — | — |
| sx | Shorthand layout props | SxProps | — | — |
Ref (LhInputTagInstance)
| Method | Description |
|---|---|
| focus() | Focus the input (clicking the container does the same) |
| commit() | Commit the current input |
Commit semantics
Empty input is silently ignored; on duplicate / over-limit the input is cleared without firing onChange — business layers sense it via onAdd / onRemove.
Accessibility
The input's aria-label comes from the locale pack (overridable via ariaLabel); the remove button's aria-label uses the locale pack ariaLabels.removeTag.
Styles
import '@lh-ui/react/style/input-tag'