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.

How to add an input field to a page. The file is components/css/input.css.

Basic Usage

Link the shared stylesheet once per page, and add the keyboard script. Never copy the rules into a page.

StepWhat to do
1. Link<link rel="stylesheet" href="/components/css/input.css">. Both templates already have it.
2. MarkupA form-field with a label, an input-wrap around an input-box holding the input, and an optional form-helper message.
3. SizeLarge is the default. Add input-box--sm and form-label--sm for Small, input-box--xs for XSmall (desktop only).
4. Keyboard focusAdd the script under CSS / Tailwind once per page. Without it the ring never shows on keyboard focus.

Input

Copy the markup you need. Hover and focus come from :hover and keyboard focus; the [data-state] selectors in the CSS exist only so the documentation can force a state.



API

Classes

ClassUse
form-fieldThe column: label, wrapper, message.
form-label, form-label--smThe label. --sm for Small and XSmall.
input-wrapThe wrapper that draws the focus ring.
input-box, --sm, --xsThe box. Large, Small, XSmall.
input-box--error, --successRed or green border.
form-inputThe native input.
input-icon, --lg, --fillA Material Symbols icon. --lg is 24px, --fill is the filled clear icon.
input-actions, __btn, __clear, __dividerThe right-hand icons.
form-helper, --error, --success, --disabledThe message.

Things to know

  • The clear button shows only while the field has a value, through :placeholder-shown. The placeholder is therefore required, even if it is a single space.
  • The Active border (black) also comes from :placeholder-shown.
  • A button next to a field uses the matching size: Input Large → btn--md, Small → btn--sm, XSmall → btn--xs.
  • The docs controls (playgrounds) are Small inputs (input-box--sm).
  • The [data-state] selectors do nothing outside the documentation pages.

CSS / Tailwind

The component is one CSS file, shared by every page. Link it, never copy it. The CSS below is read from the file the page links, so it is always what you see.

CSS (components/css/input.css)
JavaScript (focus ring on keyboard only)