Input
A native input element that automatically works with Field.
View as MarkdownUsage guidelines
- Form controls must have an accessible name: It can be created using a
<label>element or theFieldcomponent. See the forms guide.
Anatomy
Import the component and use it as a single part:
API reference
defaultValueUnion—
- Name
- Description
The default value of the input. Use when uncontrolled.
- Type
valueUnion—
- Name
- Description
The value of the input. Use when controlled.
- Type
onValueChangefunction—
- Name
- Description
Callback fired when the
valuechanges. Use when controlled.- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-disabled
Present when the input is disabled.
data-valid
Present when the input is in valid state (when wrapped in Field.Root).
data-invalid
Present when the input is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the input’s value has changed (when wrapped in Field.Root).
data-touched
Present when the input has been touched (when wrapped in Field.Root).
data-filled
Present when the input is filled (when wrapped in Field.Root).
data-focused
Present when the input is focused (when wrapped in Field.Root).
| Attribute | Description | |
|---|---|---|
data-disabled | Present when the input is disabled. | |
data-valid | Present when the input is in valid state (when wrapped in Field.Root). | |
data-invalid | Present when the input is in invalid state (when wrapped in Field.Root). | |
data-dirty | Present when the input’s value has changed (when wrapped in Field.Root). | |
data-touched | Present when the input has been touched (when wrapped in Field.Root). | |
data-filled | Present when the input is filled (when wrapped in Field.Root). | |
data-focused | Present when the input is focused (when wrapped in Field.Root). | |