Input
Edit single-line text with native input events and Field integration.
Anatomy#
Usage#
Use Input for native single-line text editing. Compose it with Field for a label and validation message, or InputGroup for adjacent addons. Use Textarea for multi-line text and NumberInput for a constrained numeric stepper.
Native attributes#
Input forwards native <input> attributes and defaults autoComplete to 'off':
valueandonValueChange: control the current text. A controlled input restores its displayed text tovalueafter every edit, so updatevaluefromonValueChange.defaultValue: sets the initial uncontrolled text and is restored on native form reset. Passingvalue={undefined}leaves the input uncontrolled.readOnlyanddisabled:readOnlykeeps the field focusable without allowing edits;disabledremoves it from interaction.
Inside a Field, Input inherits size, required, disabled, and readOnly, takes its name from the field when omitted, and links the label, description, and error through ARIA attributes.
Set variant ('outline', 'subtle', 'ghost', or 'none') and size ('sm', 'md', or 'lg') to change presentation.
Value modifiers#
modifiers transforms the text before it reaches onValueChange and form state, and sets the
callback’s value type.
| Modifier | Effect |
|---|---|
trim |
Strips surrounding whitespace, also from the displayed text on change |
lazy |
Updates the value on change (blur or Enter) instead of on every keystroke |
number |
Parses the text to a number; empty or non-numeric text gives null |
empty |
'null' turns empty text into null; 'preserve' keeps the string |
Here value is number | null. Use NumberInput when the user needs
stepping, bounds, or formatting.
Composed controls#
Use InputGroup.Leading and InputGroup.Trailing for static context such as an icon or unit.
Password visibility, clearing, copying, and loading stay in your application: compose buttons and
icons into these parts and provide their labels and handlers.
Examples#
Controlled#
Control the input value with value and onValueChange.
InputGroup addons#
Compose InputGroup addons around Input. Your application owns visibility toggles, clear buttons,
and unit suffixes, including the state and accessible labels of their buttons.
Form#
Bind Input to form.Field so schema validation owns the error. Omit name on the input; the
bound field supplies it.
API Reference#
Attributes#
data-disableddata-invaliddata-readonlydata-requiredProps#
Props for the Input component.