Input
A single-line text input that takes its label and validation from Field.
Shown in the app list and on the published WebApp.
Usage guidelines
- Use
Inputfor one line of free text. Multiline text usesTextarea, numbers with steppers useNumberField, secrets usePasswordField, and a prefix, suffix or inline action that shares the input surface usesInputGroup. - Put the input in a
Fieldwith aFieldLabel. The field owns the label,FieldDescriptionandFieldErrorrelationships and thenamethe value submits under. - Use
aria-labelonly when the layout has no place for a visible label, such as a search box in a toolbar. Aplaceholdershows an example value and is never the name. - Inputs that save together belong in a real form boundary:
Formor a native<form>, with aButtonoftype="submit". Keep the submit button enabled while the form is incomplete; submitting runs validation. - Set the native attributes that describe the value:
type,autoComplete,inputModeandspellCheck={false}for URLs, emails and identifiers. Inputhas a single size. Usedisabledfor a value the user cannot change now, andreadOnlyfor a value that can be selected and copied but not edited.
Anatomy
Examples
States
Set invalid on the Field when application code owns the validity, and render <FieldError match> while it is invalid; editing the URL to include https:// clears the error. disabled on the Field disables the label and the input together. A read-only input keeps its focus ring so keyboard users can reach and copy the value.
Validation in a form
Native constraints such as required and type="url" drive FieldError. Each match value names the validity state its message covers. Submit the empty form to see the messages; after a submit, they update as the value changes.
Without a visible label
A search box in a toolbar sits next to the title of the list it filters, so it has no room for a label of its own. It takes aria-label instead; the placeholder alone would not name it. The <search> element around it marks the search landmark.
Apps
- Customer support botChatflow
- Release notes writerWorkflow
- Contract reviewerWorkflow
- SQL query assistantAgent
API reference
Input
A standalone single-line text input that integrates with Field. Renders an <input> element.
Use InputGroup with InputGroupInput when the field needs a prefix, suffix, or inline action.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: InputState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, InputState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: InputState) => React.CSSProperties | undefined) | No default | |
onValueChange | ((value: string, eventDetails: BaseInput.ChangeEventDetails) => void) | No default | |
defaultValue | string | number | readonly string[] | No default | |
value | string | number | readonly string[] | No default | |
| Attribute | Description |
|---|---|
data-disabled | Present when the input is disabled. |
data-valid | Present when the input is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the input is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the input has been touched (when wrapped in Field.Root). |
data-dirty | Present when the input's value has changed (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). |