Skip to main contentSkip to docs navigation

Chassis

Form Inputs

View on GitHub

Style input, select, and textarea elements with a single class — three sizes, disabled and read-only states, and plaintext and ghost variants.

@layer components
Component tokens

The examples on this page leave out labels to keep the markup on the class they demonstrate. In production, give every input a <label> or an aria-label, so the control has an accessible name.

Introduction

The .form-input class gives <input>, <select>, and <textarea> elements the same typography, padding, border, colors, and focus ring. Size modifiers, the native disabled and readonly attributes, and the plaintext and ghost variants build on that one class.

Basic structure

Add .form-input to an <input>, a <select>, or a <textarea> element. Inputs are block-level and take the full width of their container.

HTML
<input class="form-input" type="text" placeholder="Example text input">
<select class="form-input">
  <option value="">Example select</option>
  <option value="option1">Option one</option>
  <option value="option2">Option two</option>
</select>
<textarea class="form-input" placeholder="Example textarea"></textarea>

The caret of a select is a background image that follows the disabled state and dark mode. Change the icon with Chassis Tokens, or override the custom properties at runtime.

Select

A <select> with .form-input shows a caret at its inline end. The caret is removed for the list forms of a select: add the multiple attribute to allow several selections.

HTML
<select class="form-input" multiple>
  <option value="option1">Option one</option>
  <option value="option2">Option two</option>
  <option value="option3">Option three</option>
</select>

Set the size attribute to show a fixed number of options as a list.

HTML
<select class="form-input" size="3">
  <option value="option1">Option one</option>
  <option value="option2">Option two</option>
  <option value="option3">Option three</option>
</select>

Textarea

A <textarea> with .form-input is at least as tall as an input. Set the rows attribute for a taller one.

HTML
<textarea class="form-input" placeholder="Example textarea with rows attribute" rows="4"></textarea>

Sizing

Add .sm or .lg to a .form-input to change its height, padding, and font size. The sizes match the sizes of buttons and the other form components.

HTML
<input class="form-input lg" type="text" placeholder="Large input">
<input class="form-input" type="text" placeholder="Default input">
<input class="form-input sm" type="text" placeholder="Small input">

States

Form inputs style the native disabled and readonly states, so no state class is needed.

Disabled inputs

Add the disabled attribute to an input to make it unavailable. The input takes the disabled form colors, and the browser removes it from the tab order and from form submission.

HTML
<input class="form-input" type="text" placeholder="Disabled input" disabled>
<input class="form-input" type="text" value="Disabled input with value" disabled>
<select class="form-input" disabled>
  <option value="">Disabled select</option>
  <option value="option1">Option one</option>
  <option value="option2">Option two</option>
</select>

Readonly inputs

Add the readonly attribute to keep the value of an input from changing while it stays selectable. Unlike a disabled input, a read-only input remains focusable and is submitted with the form.

HTML
<input class="form-input" type="text" value="Readonly input" readonly>
<input class="form-input" type="text" value="Readonly disabled input" readonly disabled>

Plaintext inputs

Combine readonly with the .plaintext class to show a value as plain text: the class removes the background and the border and keeps the padding, so the text aligns with the inputs next to it.

HTML
<input class="form-input plaintext" readonly type="text" value="email@example.com">
<input class="form-input" type="password" autocomplete="current-password" placeholder="Password">
HTML
<form class="d-flex flex-wrap gap-md">
  <div>
    <input class="form-input plaintext" readonly type="text" value="email@example.com">
  </div>
  <div>
    <input class="form-input" type="password" autocomplete="current-password" placeholder="Password">
  </div>
  <div>
    <button type="submit" class="button primary">Submit</button>
  </div>
</form>

Input types

.form-input applies to every text-like type of <input>, such as text, password, email, and number. The file, color, and date types have rules of their own.

File input

On an <input type="file">, .form-input styles the file selector button with the colors of an input addon. Choosing files stays the browser's own dialog.

HTML
<input class="form-input" type="file">
<input class="form-input" type="file" multiple>
<input class="form-input" type="file" disabled>

Color input

On an <input type="color">, .form-input sizes the swatch to the height of an input and rounds it with the radius of the form controls.

HTML
<input class="form-input" type="color" value="#0094b8">

Display and sizing utilities set the width of a color input and place several on one line.

HTML
<input class="form-input d-inline-flex w-25 me-md" type="color" value="#0094b8">
<input class="form-input d-inline-flex w-25" type="color" value="#f55200">

Date and time

The date, time, and datetime-local types keep the picker of the browser, and .form-input gives them the height of the other inputs.

HTML
<input class="form-input" type="datetime-local" value="2026-11-16T17:57">
<input class="form-input" type="date" value="2026-11-16">
<input class="form-input" type="time" value="17:57">

Datalists

Connect a text input to a <datalist> element with the list attribute to suggest values while the user types. The input still accepts any text.

HTML
<input type="text" class="form-input" list="datalistOptions" placeholder="Type to search...">
<datalist id="datalistOptions">
  <option value="Option one"></option>
  <option value="Option two"></option>
  <option value="Option three"></option>
</datalist>

Ghost inputs

The .ghost-input class removes the background, the border, and the padding of an input and leaves the styling to a wrapper, for custom controls that hold an input next to other content.

.ghost-input also removes the focus outline of the input, so the wrapper has to show the focus, for example with :focus-within.

HTML
<input class="ghost-input" type="search" placeholder="Search items">

Form input wrapper

A .form-input element around a ghost input is that wrapper: it draws the border, the padding, and the size variants, shows the focus ring while the input inside has focus, and takes the disabled colors when the input is disabled.

HTML
<div class="form-input">
  <input class="ghost-input" type="search" placeholder="Search items">
</div>
<div class="form-input">
  <input class="ghost-input" type="search" placeholder="Search items" disabled>
</div>
<div class="form-input lg">
  <input class="ghost-input" type="search" placeholder="Search items">
</div>
<div class="form-input sm">
  <input class="ghost-input" type="search" placeholder="Search items">
</div>

CSS

The Form input component can be customized at both runtime (via custom properties) and compile time (via Sass variables).

Custom properties

The Form input component exposes CSS custom properties to control its appearance at runtime.

The color properties of a form input in its idle, focused, and disabled states:

--fg-color: var(--input-fg-color, var(--form-idle-fg-active));
--bg-color: var(--input-bg-color, var(--form-idle-bg-regular));
--border-color: var(--input-border-color, var(--form-idle-border-color));
--icon-color: var(--input-icon-color, var(--form-idle-fg-active));

The sizing and spacing properties, which the .sm and .lg modifiers reassign:

@include map-font($form-md-text-font, input);
--padding-x: var(--input-padding-x, #{$form-md-padding-x});
--padding-y: var(--input-padding-y, #{$form-md-padding-y});
--gap: var(--input-gap, #{$form-md-gap});
--min-height: var(--input-min-height, #{$form-input-min-height});
--border-width: var(--input-border-width, #{$form-regular-border-width});
--border-radius: var(--input-border-radius, #{$form-md-border-radius});
--caret-size: var(--input-caret-size, #{$form-md-caret-size});
--icon-size: var(--input-icon-size, #{$form-md-icon-size});

The colors of the selector button of a file input:

--file-button-fg-color: #{$form-file-button-fg-color};
--file-button-bg-image: #{$form-file-button-bg-image};
--file-button-bg-color: #{$form-file-button-bg-color};
--file-button-bg-hover: #{$form-file-button-bg-hover};

The forms overview lists the custom properties that all form elements share.

Sass variables

The Form input component uses Sass variables in scss/config/_defaults.scss to define its defaults.

The variables of all form inputs:

$form-input-plaintext-color:            var(--fg-main);
$form-input-min-height:                 calc(var(--line-height) + var(--padding-y) * 2);
$form-input-box-shadow:                 none; // var(--box-shadow-inset);
$form-input-focus-ring-color:           $focus-ring-color;
$form-input-focus-ring-offset:          0px;
$form-input-transition:                 border-color .15s ease-in-out, box-shadow .15s ease-in-out;

The variables of file inputs:

$form-file-button-fg-color:             $input-addon-fg-color;
$form-file-button-bg-image:             $input-addon-bg-image;
$form-file-button-bg-color:             $input-addon-bg-color;
$form-file-button-bg-hover:             var(--default-bg-even);

The forms overview lists the Sass variables that all form elements share.

Design tokens

Form inputs have no tokens of their own: they use the design tokens that all form elements share, listed in the forms overview.