Luke UI
ComponentsForms

Text Field

Single-line text input with label, validation, and adornments.

Use TextField for a single text input with label, description, validation, and optional adornments built in.

Text Field — Basic
We'll only use this for account updates.

Best practices

GuidancePractices
DoUse label for every field where possible. It works better with assistive technology and autofill than aria-label alone.
Don'tUse placeholder as a label substitute. It disappears after typing and often fails colour contrast requirements.

Required fields

Use isRequired and necessityIndicator to communicate mandatory fields. 'icon' renders a visual required marker. 'label' appends "(required)" to the label text.

Text Field — Required

Validation

Pass field-level validation through React Aria Form. Use errorMessage to render the validation message.

import { Form } from 'react-aria-components';

<Form validationErrors={{ username: 'Username is not available.' }}>
	<TextField
		name="username"
		label="Username"
		errorMessage={(validation) => validation.validationErrors.join(' ')}
	/>
</Form>;

Adornments

Use adornmentStart and adornmentEnd to place non-editable content inside the input chrome. Adornments accept any ReactNode. If an adornment is interactive, you are responsible for its semantics.

Text Field — Adornments

Size

size controls height and typography. The HTML numeric <input size> attribute is intentionally omitted because size is reserved for the design-system variant.

ValueDescription
'small'Compact input height.
'medium'Default input height.
Text Field — Sizes

Accessibility

When visual context already communicates purpose, you may omit label and provide an accessible name with aria-label or aria-labelledby on the field.

<TextField aria-label="Search" name="search" placeholder="Search" />

Primitive

Use the TextInput primitive when you need the input without the label, description, and error slots that TextField provides.

Props

Prop

Type