Input

A native input element that automatically works with Field.

Base UI React 1.8.0
FineSoft Stencil

The Stencil example uses fs-input directly. It renders a native input, supports native labels and forms, and emits valueChange with event.detail.value for controlled consumers. inputRef exposes the native input for selection, files, and validity APIs. No component-specific controller is supplied by the docs.

Field is available for the Stencil example: it supplies validation, label registration, and field-state attributes. The migrated Form adds inherited validation mode, consolidated values, form-level errors, and submit validation when the Input is used through Field. React render, function-valued className/style, and React context are not Web Component APIs. Outside Field, the original Input also leaves data-valid, data-touched, data-dirty, data-filled, and data-focused unset. Like the original, canceling a value notification does not undo an already-performed native uncontrolled edit; a controlled consumer keeps its value unchanged to reject that edit.

Usage guidelines

  • Form controls must have an accessible name: It can be created using a <label> element or the Field component. See the forms guide.

Anatomy

Import the component and use it as a single part:

Anatomy

API reference

defaultValueUnion
Description

The default value of the input. Use when uncontrolled.

Type
valueUnion
Name
Description

The value of the input. Use when controlled.

Type
onValueChangefunction
Description

Callback fired when the value changes. Use when controlled.

Type
classNamestring | function
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 ReactElement or 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 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-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 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-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).

Input.PropsHide

Re-Export of Input props as InputProps

Input.StateHide

Input.ChangeEventReasonHide

Input.ChangeEventDetailsHide