input
Retrieve text input from a user.
default
prefix and suffix
disabled
search
Automatically clears the input if escape is pressed.
error
An error message.
An error message.
An error message.
label
rounded prefix and suffix
rounded prefix and suffix without styling
best practices
When to use
- Use
Inputfor a single line of free-form text such as names, domains, or tokens. - Switch to
Textareathe moment content can wrap to multiple lines. - Use
Comboboxwhen the value comes from a known list the user filters by typing. - For an inline search box, use
SearchInputwith a scoped placeholder likeSearch projects; do not embed it inside an unrelated form.
Behavior
- Validate on blur, not on every keystroke; surface the message with the
errorprop. - Trim leading and trailing whitespace before submit so
example.comandexample.comresolve to one value. - Keep the field focusable while saving; pair
disabledwith a spinner only when input is impossible. - Do not wrap a labelled
Inputin aTooltip; put the explainer on a sibling icon button so the label stays announced.
Content
- Labels are short Title Case nouns such as
Project Name,Domain, orEnvironment Variable Name. - Placeholders show an example value such as
my-awesome-projectorexample.com, never instructions. - Helper text is sentence case, one sentence with a trailing period, on a sibling
element wired through
aria-describedby. - Validation names the field and the constraint, ends in a period, and skips "please":
Project name is required.andCode must be 6 digits..
Accessibility
- Passing a string to
labelassociates it with the input automatically; provide anidwhen you need a stable ID for external labels or references. - For icon-only affordances, use a circular button with an accessible name such as
aria-label="Clear search"rather than an unlabeled icon. - A
SearchInputplaceholder names the scope, such asSearch projects, so its purpose is clear without sighted context.