Skip to content

UI: TextField

View as Markdown

A labelled text input with an optional description and error message. Import the token file once (@pithyx/ui/tokens.css) and wrap the app in UiProvider; see @pithyx/ui.

Generated from the TSDoc comments of @pithyx/ui 1.0.0-rc.9 at build time; the text below the headings is the comment in the source.

The props of TextField: React Aria’s text field props plus label, hints and an error.

  • Omit<AriaTextFieldProps, "className" | "children">
label: ReactNode;

The visible label, also the accessible name.

optional description?: ReactNode;

A hint below the input, announced with it.

optional errorMessage?: ReactNode;

The text shown while the field is invalid (isInvalid or a failed validate).

optional placeholder?: string;

A hint inside the empty input; never a replacement for the label.

optional className?: string;

Extra class names for the field, added after its own.

optional inputClassName?: string;

Extra class names for the input element.

optional autoCapitalize?: "none" | "characters";

“none” for user names and codes, so phones do not capitalize the first letter.

optional trailing?: ReactNode;

Trailing content inside the input frame, for example a reveal button.

function TextField(props): Element;

A labelled text input with an optional description and error message. Set autoComplete as the form needs it (username, email), so password managers and browsers fill it in.

Parameter Type Description
props TextFieldProps React Aria’s text field props (value, onChange, isRequired, validate) plus label, hints and error.

Element

The field with label, input, description and error.

<TextField label="Name" value={name} onChange={setName} isRequired />