Appearance
Text input
Lets people type a short text, a number or a longer note.
base-baseinputtext--defaultOpen in Storybook ↗When to use
- Free text and numbers in forms, inline editors and filters: Title, Year, Description.
- A longer note: use the multi-line field.
- A colour value: use the colour variant, which pairs a swatch with the hex code.
When not to use
- A choice from a fixed list: use a dropdown.
- Links to other records or several tags: use an autocomplete.
- A date or a date and time: use a date picker.
- An option that is on or off: use a checkbox or a toggle.
Anatomy
- Field:
--radius-inputcorners,--input-padding, at least--control-heighthigh, the same height as the dropdown, date picker and autocomplete. The value is set in--text-input. - Border:
--color-border-default, one step darker on hover (--color-input-border-hover). - Placeholder (optional):
--color-text-placeholder. - Error message (optional): below the field, in
--color-danger. The field shows it; the input does not draw it itself.
The label is not part of the input. It comes from the surrounding form or field row.
Variants
| Variant | Where | Looks |
|---|---|---|
| Bordered | every field that stands on its own — use this by default | white with a border |
| Borderless | inside another control, such as a filter | white, no border |
| Number | numeric values | right-aligned, no spinner buttons |
| Compact | a value inside a chip, such as a page number on a relation | --control-height-compact, --input-padding-compact, label-size text |
| Multi-line | longer notes | at least three rows (--textarea-min-height); drag the corner to make it taller |
| Growing multi-line | long values that should show in full | grows with its content; it never scrolls and has no resize handle |
| Colour | colour values | a swatch that opens the browser's colour picker, next to a field with the hex code; both stay in sync |
base-baseinputcolor--defaultOpen in Storybook ↗In an inline editor, a multi-line field grows with its content up to six rows (--textarea-max-height) and then scrolls.
States
| State | What you see | Trigger |
|---|---|---|
| Resting | white field, default border | — |
| Hover | border one step darker | pointer |
| Focus | --focus-ring-width ring in --color-focus-ring | click or Tab |
| Placeholder | example text in placeholder ink | empty field with a placeholder |
| Error in a form | default border, message below the field | the form is checked and the value is invalid |
| Error in an inline editor | --color-danger border, message below the field | saving the value failed or it is invalid |
| Disabled | --color-surface-muted fill, --color-text-disabled ink, subtle border | the field is unavailable |
base-baseinputtext--statesOpen in Storybook ↗Leading and trailing spaces are removed from a text value. A number field that holds something that isn't a number reports an invalid value, so the form can show an error instead of keeping the old number.
Keyboard & accessibility
- It is a native
<input>or<textarea>: Tab reaches it and all the usual editing keys work. - Every field needs a name: a visible label linked to it, or an
aria-labelsuch as Title when there is no visible label. - In an inline editor, the error is linked to the field. The message is a
role="alert", so it is announced when it appears; it is connected to the field witharia-describedby, and the field getsaria-invalid="true". - In a form, the error is plain text under the field. It is not linked to the field and not announced.
- In the colour variant, the hex field is a normal text field, so the value can always be typed instead of picked.
Content
- Labels are nouns, in sentence case and without a colon: Title, Date of birth.
- A placeholder is an example, not an instruction: e.g. 1958, not Enter a year. It never replaces the label.
- Error messages say what is wrong and how to fix it: Title is required, ISBN is not valid.
Related
Dropdown · Autocomplete · Date picker · Tooltip · Content · Accessibility