Input
@rockshin/tao-uiSingle-line text input for short freeform values.
When to use
Use Input for short text values such as names, filters, search terms, and identifiers.
Recommended
- Pair with FormField for labels and validation.
- Use type, inputMode, and autoComplete when applicable.
Avoid
- Do not use the component outside its intended interaction model.
Examples
Basic usage
Variants
Sizes and affixes
Three sizes
Choose a size for regular forms, compact toolbars, or spacious layouts.
Clear and count
Clearing calls onChange and onClear. Controlled values remain owned by your state.
Prefixes and suffixes
Affixes show units or context while the input value contains only user data.
Password input
The visibility button supports keyboard access, disabled state, and controlled visibilityToggle.
Search input
Button clicks, Enter and clearing call onSearch with source input or clear. IME confirmation and loading do not submit a search.
Native constraints and read-only
Use native email, required, maxLength, and readOnly; application state decides error feedback.
Cursor placement
The ref remains the native input. InputRef also exposes input, nativeElement and extended focus options.
Custom counting
count.max warns by default. strategy and exceedFormatter can count and clip Unicode code points. Native maxLength counts UTF-16 code units independently.
Text area
Input.TextArea is the same component as standalone Textarea, with auto sizing, clearing, counting and Enter events.
One-time code
Supports automatic advance, pasting, arrow keys, Backspace, formatting and masking. onInput returns an array including empty slots; onChange fires only when complete.
Attached content
addonBefore / addonAfter attach labels; prefix / suffix sit inside the input area.
API
Input / Input.TextArea
Other props pass through to the native input / textarea. Input.TextArea does not accept prefix, suffix or addons; standalone Textarea remains compatible.
A count limit does not clip unless count.exceedFormatter is set. Clipping waits for IME composition to finish. count.show takes precedence over showCount. Input semantic parts: root / input / prefix / suffix / clear / count / addonBefore / addonAfter. TextArea: root / textarea / clear / count.
Input.Password
Inherits Input props.
Input.Search
Inherits Input props. The search button does not submit a surrounding form; onSearch reports source input or clear.
Input.OTP
Ref
Input, Password and Search refs remain HTMLInputElement; TextArea remains HTMLTextAreaElement. Exported InputRef / TextAreaRef types add focus({ preventScroll, cursor: 'start' | 'end' | 'all' }), blur(), nativeElement and input / textArea. Native types without selection support only receive focus. OTPRef exposes focus(), blur() and nativeElement.
The API follows local Ant Design 6.7.0 while retaining tao-ui native refs, theming and semantic DOM contracts; it is not a drop-in antd replacement. Deprecated bordered, prefixCls and antd component-global configuration are not supported. Set underlined through the local Input-family variant prop.