Components · Form

Input

An input field lets the user enter free text, numbers or search terms. It can have a label, a left icon, right-hand action icons and a message that explains or validates the value.

Every example on this page is the real component, not a picture. Type, click, tab and clear the value to try it. Figma: Base Input.

Playground

Choose a breakpoint, size and state and the field and its code update. Hover and focus are forced here so they can be seen; type in the field to get the Active state, and use the clear button to empty it.

Breakpoint
Size
Left icon
Right icons
Message icon

Markup for this selection

HTML

Overview

An input field lets the user enter free text, numbers or search terms. It can have a label, a left icon, right-hand action icons and a message that explains or validates the value.

Input has three sizes on desktop (Large, Small, XSmall) and two on mobile (Large, Small), seven states, and optional clear and action icons.

This documentation has three pages. Examples & Guidelines (this page) shows when and how to use an input field. Specifications holds the values: tokens, sizes, measurements, states and requirements. Code shows how to add one to a page.


Usage

When to use

Use an input when the user types a value that is not picked from a list. Use it to:

  • Enter free text, such as a name or an order number
  • Enter a number or a code
  • Search, with a left search icon and the clear button
  • Enter a value that can also be filled by an action, such as “Use my location” or “Scan a code” (action icons)

When not to use

For a value picked from a list

When the user picks one value from a fixed list, use eco-select. For one of two or three options use eco-radio, and for any number of options eco-checkbox. For several lines of text use eco-textarea.

For a label

A placeholder is not a label: it disappears when the user types, and it is easy to miss. Every field has a visible label.

Do give every field a visible label.
Do not use the placeholder as the label.

Say what is wrong

An invalid field says what is wrong in the message, with the error icon. A red border alone is easy to miss and is not enough for everyone.

Do explain what is wrong in the message, with the error icon.
Do not rely on a red border alone.

Quick reference

The user…Use
types free text, a number or a search termInput
types several lines of texteco-textarea
picks one value from a fixed listeco-select
picks one of two or three optionseco-radio
picks any number of optionseco-checkbox

Do

  • Give every field a visible label, in sentence case for values and uppercase for the label itself.
  • Pick the size by breakpoint: Large for standard forms, Small for compact surfaces, XSmall for dense tables.
  • Explain what is wrong in the message, with the error icon.
  • Use pre-filled or detected values where you can, in sentence case.

Don’t

  • Use a placeholder as the label.
  • Show the focus ring on mouse click, or remove it on keyboard focus.
  • Use color alone for error or success.
  • Hardcode the colors or the heights: use the tokens and the size classes.

Anatomy

Input

  1. Label. label-md or label-sm, uppercase, 4px above the box.
  2. Left icon. 24px (Large) or 20px (Small, XSmall), 8px from the text. It shows the type of input; the default is search.
  3. Input text. body-md (Large) or body-sm. The placeholder is text-tertiary.
  4. Clear. Only with a value. A real button with an aria-label.
  5. Divider. 1px × 16px, between clear and the action icons.
  6. Action icons. Optional buttons for actions such as “Scan a code”.
  7. Message. body-sm, 4px below the box. Hint, error or success.

The focus ring is a separate element around the box, 2px and 3px outside it, so focusing never changes the layout or the box size.


Variants

An input can have a left icon, right-hand icons and a message. Enable only the ones the field needs. Sizes are under Sizes below.

Icons

A left icon shows the type of input (the default is search). Right-hand icons are optional: clear appears only when the field has a value, a divider separates clear from the action icons. Enable only the ones the field needs.

Messages

The message sits below the field, in body-sm. Hint text is neutral, error and success change the color of the border and the message. The message icon is optional and up to you; an icon next to an error message helps so color is not the only signal.


Sizes

Three sizes on desktop (Large 48px, Small 40px, XSmall 32px) and two on mobile (Large 40px, Small 32px). Figma has a Breakpoint property: Desktop is 769px and up, Mobile is below 769px. The component switches by itself; the Breakpoint toggle forces one for preview.

Breakpoint

Large is for standard forms, Small for compact surfaces, XSmall for dense tables and filters (desktop only: on mobile it is not available, use Small). Measurements are under Sizes in Specifications.


Layout & Appearance

Width

The field is as wide as its container: set the width on the container, not on the field. In the examples on this page the container is 360px or narrower.

Appearance

The box has a 1px border and a white fill. The border turns black when the field has a value, and the message and the border turn red or green for error and success. The focus ring is a 2px blue frame around the box. Token names and values are under Design Tokens in Specifications.


Behavior

Typing

When the user types a value the field becomes Active: the border turns black and the clear button appears.

Clear

The clear button empties the field and returns focus to it. It is a real button with an aria-label.

Hover and focus

Hover changes the border. Hover on a right icon gives a grey fill (Button) or turns the icon grey (Icon Button). The blue ring shows on keyboard focus only (body.keyboard-nav, set by a small script). All states are listed under States in Specifications.

Error and success

Set aria-invalid="true" on an invalid field and point aria-describedby at the message. The message says what is wrong.

Disabled

A disabled field is not focusable. It has a grey fill, a light border, and text-disabled for the text, the icons and the message.


Accessibility

All requirements are listed under Accessibility Requirements in Specifications.

Keyboard support

Tab moves into and out of the field and to the icon buttons. The focus ring shows on keyboard focus only. Add the keyboard script once per page (see Code).

Screen reader support

Every field has a label with for and id. A search field without a visible label needs an aria-label. An invalid field gets aria-invalid="true" and aria-describedby that points at the message.