Text Field

A single-line text input component for collecting user input such as names, emails, search queries, and other short text entries.

Overview

type
text · password · email · number · tel · url · search
size
large · medium · small · tiny
Toggles
autoFocus, multiline, disabled, error, required

All options

Size and state

Large is 48px tall, matching a large Button. Medium (default), small and tiny step down from there.

size \ stateenablederrordisabled
large

Enter a valid email address

medium

Enter a valid email address

small

Enter a valid email address

tiny

Enter a valid email address

Input types

Supports text, password, email, number, tel, url, and search types.

type \ sizemedium
text
password
email
number
tel
url
search

Label and required

A required field marks its label with an asterisk.

Multiline

multiline renders a textarea with maxRows rows (default 6).

Examples

Submit on Ctrl/Cmd+Enter

Use the onSubmit prop to handle submission when the user presses Ctrl+Enter (or Cmd+Enter on Mac).

Accessibility

Label

When label is set it renders a <label> tied to the input by id.

Error message

With error set, the input gets aria-invalid and aria-describedby pointing at the errorText message.

Mobile keyboard

The number, tel, email, url and search types set a matching inputMode, so mobile devices show a suitable keyboard.

Props

PropTypeRequiredDescription
idstringYes—
labelstringNo—
valuestringYes—
type'text' | 'password' | 'email' | 'number' | 'tel' | 'url' | 'search'No—
onChange(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => voidYes—
onBlur(e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => voidNo—
onFocus(e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => voidNo—
onKeyDown(e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => voidNo—
onSubmit() => voidNo—
autoFocusbooleanNo—
multilinebooleanNo—
maxRowsnumberNo—
disabledbooleanNo—
errorbooleanNo—
errorTextstringNoMessage shown under the field when `error` is true
requiredbooleanNo—
size'large' | 'medium' | 'small' | 'tiny'No—
placeholderstringNo—
namestringNo—
autoCompletestringNoBrowser autofill hint, e.g. "username" or "current-password". Defaults to "off".
tabIndexnumberNo—