Skip to content

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 ​

Anatomy ​

  1. Field: --radius-input corners, --input-padding, at least --control-height high, the same height as the dropdown, date picker and autocomplete. The value is set in --text-input.
  2. Border: --color-border-default, one step darker on hover (--color-input-border-hover).
  3. Placeholder (optional): --color-text-placeholder.
  4. 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 ​

VariantWhereLooks
Borderedevery field that stands on its own — use this by defaultwhite with a border
Borderlessinside another control, such as a filterwhite, no border
Numbernumeric valuesright-aligned, no spinner buttons
Compacta value inside a chip, such as a page number on a relation--control-height-compact, --input-padding-compact, label-size text
Multi-linelonger notesat least three rows (--textarea-min-height); drag the corner to make it taller
Growing multi-linelong values that should show in fullgrows with its content; it never scrolls and has no resize handle
Colourcolour valuesa 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 ​

StateWhat you seeTrigger
Restingwhite field, default border—
Hoverborder one step darkerpointer
Focus--focus-ring-width ring in --color-focus-ringclick or Tab
Placeholderexample text in placeholder inkempty field with a placeholder
Error in a formdefault border, message below the fieldthe form is checked and the value is invalid
Error in an inline editor--color-danger border, message below the fieldsaving the value failed or it is invalid
Disabled--color-surface-muted fill, --color-text-disabled ink, subtle borderthe 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-label such 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 with aria-describedby, and the field gets aria-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.

Dropdown · Autocomplete · Date picker · Tooltip · Content · Accessibility

Powered by Elody - Open Source Semantic Data Platform