useTextField

Provides the behavior and accessibility implementation for a text field.

Example
TextField.tsx
TextField.css
Form.css
import {TextField} from './TextField';

<TextField label="Email" />

API

Shows a text field component with labels pointing to its parts, including the input, and label elements.ValueLabelInputLabelHelp textDescription or error message
<TextField>
  <Label />
  <Input /> or <TextArea />
  <Text slot="description" />
  <FieldError />
</TextField>
useTextField<T extends = >(props: <T>, ref: <T>): <T>

AriaTextFieldProps

NameTypeDefault
enterKeyHint'enter''done''go''next''previous''search''send'Default:

An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See MDN.

isDisabledbooleanDefault:

Whether the input is disabled.

isReadOnlybooleanDefault:

Whether the input can be selected but not changed by the user.

placeholderstringDefault:

Temporary text that occupies the text input when it is empty.

type'text''search''url''tel''email''password'string{}Default: 'text'

The type of input to render. See MDN.

inputMode'none''text''tel''url''email''numeric''decimal''search'Default:

Hints at the type of data that might be entered by the user while editing the element or its contents. See MDN.

autoCorrectstringDefault:

An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See MDN.

spellCheckstringDefault:

An enumerated attribute that defines whether the element may be checked for spelling errors. See MDN.

valuestringDefault:

The current value (controlled).

defaultValuestringDefault:

The default value (uncontrolled).

onChange(value: T) => voidDefault:

Handler that is called when the value changes.

TextFieldAria

NameType
inputProps<>

Props for the input element.

labelPropsDOMAttributesLabelHTMLAttributes<HTMLLabelElement>

Props for the text field's visible label element, if any.

descriptionPropsDOMAttributes

Props for the text field's description element, if any.

errorMessagePropsDOMAttributes

Props for the text field's error message element, if any.

validationDetailsValidityState

The native validation details for the input.