Luke UI
GitHub repository

Text Field

Captures a single line of text with a label, validation, and an optional prefix or suffix.

Use TextField to collect a single line of text. It combines an input with a label, description, and validation message.

Text Field — Basic
Use the address you check most often.

Labels and placeholders

Give the field a visible label where possible. Use placeholder for an example value or input format, not as the label. A placeholder disappears while someone types and is not a reliable accessible name.

When a nearby heading already names the field, omit label. Use aria-label or aria-labelledby instead.

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

Required fields

Set isRequired for required fields. necessityIndicator="icon" adds a visual marker. necessityIndicator="label" appends “(required)” to the label.

Text Field — Required

Validation

Set isRequired, type, or pattern, or pass validate to check the value. TextField shows its validation message after validation fails. Pass errorMessage only for an error you already have, such as one from a form library or your server. A non-empty message marks the field invalid. Read Validation for where messages come from, server errors, and how to write them.

Text Field — Validation

Prefix and suffix

Use prefix and suffix for content inside the input, such as a search icon, currency code, or URL scheme. Both accept any ReactNode. Give an interactive prefix or suffix an accessible name and keyboard behaviour.

Text Field — Prefix and suffix

Size

Use size to set the input height and typography. Use small in compact layouts. medium is the default. The HTML numeric size attribute is unavailable because size is the Luke UI variant.

Text Field — Size
Small
Medium

Accessibility

Give the field a visible label where possible. A placeholder is not a reliable accessible name.

Luke UI associates the label, description, and error message with the control.

Use the InputGroup primitives when you need an input without the label, description, and error slots. Also use them for a composition that prefix and suffix cannot express.

API

TextFieldProps also accepts compatible DOM and ARIA attributes and event handlers for its rendered element.

Prop

Type