Input
Retrieve text input from a user.
⌘K
Displays the ⌘ K shortcut to indicate that the input supports a command palette.
Transitions to showing Esc when the field is dirty.
Esc⌘K
Error
An error message.
An error message.
An error message.
An error message.
Best Practices
When to use
- Pick
<Input>for a single line of free-form text such as names, domains, or tokens. - Switch to Textarea the moment content can wrap to multiple lines.
- Use Combobox when the value comes from a known list the user filters by typing.
- For an inline search box, set the
searchvariant with a scoped placeholder likeSearch projects; don’t embed a<SearchInput>inside an unrelated form.
Behavior
- Validate on blur, not on every keystroke; surface the message by passing a string to
error. - 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. - Don’t wrap a labelled
<Input>in a Tooltip; put the explainer on a sibling icon button so the label stays announced.
Content
- Labels are short Title Case nouns:
Project Name,Domain,Environment Variable Name. - Placeholders show an example value (
my-awesome-project,example.com), never instructions likeEnter your project name. - 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.,Code must be 6 digits.).
Accessibility
- Passing a string to
labelrequiresid; theInputPropsWithStringLabelAndIdunion won’t compile without it and screen readers lose the association. - For icon-only affordances inside a row of inputs, use
<Button shape="circle" svgOnly aria-label="…">rather than an unlabeled icon. - A
SearchInputplaceholder names the scope (Search projects) so the role is clear without sighted context.
Was this helpful?