Form
Text input
Published on
Description
A text input accepts short, single-line text from the user. It is the default input type and should include a visible label, optional hint text, and error message support.
Example
Accessibility
- Use explicit
<label for="id">association — not wrapping inputs in<label>. Explicit association provides better voice control support. - Inherit typography on inputs:
font: inherit; letter-spacing: inherit; word-spacing: inherit;. Thefontshorthand does not cascadeletter-spacingandword-spacing, breaking WCAG 1.4.12 (Text Spacing). - Do not disable inputs. Users cannot understand why interaction is blocked.
- Do not use
readonly— screen reader support is inconsistent and there is no default visual styling.
References
- Under-Engineered Text Boxen (opens in new tab) — Adrian Roselli
- My Priority of Methods for Labeling a Control (opens in new tab) — Adrian Roselli
- Don't Disable Form Controls (opens in new tab) — Adrian Roselli
- Avoid Read-only Controls (opens in new tab) — Adrian Roselli
Related
- Textarea — for multi-line text
- Email input — for email addresses
- Errors — for error handling patterns
Variables
None for input