Controls
Inputs, selects and textareas are full width, with a label above and room for helper text below.
Write a plain form. Each control fills the width, and a control inside its
label sits right under the label text. Buttons, submit buttons
included, keep the width of their text.
Select
A select gets a chevron. Where the browser supports a customizable select, the option list follows the theme too.
Textarea
A textarea grows with its text, from 4 to 16 lines, where the browser supports
field-sizing. A rows attribute keeps a fixed height.
Helper text
A small right after a control is its helper text. Link it with aria-describedby.
Fieldset
A fieldset groups related controls under a legend.
disabled on the fieldset turns off and fades every control inside.
Side by side
Put controls in a .grid to place them in columns that stack on narrow screens.
Output
output shows a computed value in bold with even digit widths, so it does not shift as it changes.
Disabled and read only
Sizes
Styles
.rounded gives pill corners, .square removes them and .outlined makes the background transparent.
Variables
Buttons and inputs share the --i-control- variables.
| Variable | Default |
|---|---|
--i-control-padding-blockControls: buttons and inputs | 0.4rem |
--i-control-padding-inline | 0.875rem |
--i-control-disabled-opacity | 0.5 |
--i-label-font-weight | var(--i-font-weight) |
--i-input-outline-widthInputs: text, select and textarea | var(--i-focus-ring-width) |
--i-textarea-min-heightGrowth range of a textarea without rows, where field-sizing is supported | 4lh |
--i-textarea-max-height | 16lh |
--i-input-color-text | light-dark(#23262c, #e0e3e7) |
--i-input-color-background | light-dark(#fbfcfd, #1c212c) |
--i-input-color-border3:1 against the page, as WCAG asks for control boundaries | light-dark(#878fa2, #636c84) |
--i-input-color-placeholder | light-dark(var(--i-color-subtle), #8891a4) |
--i-input-selected-color-background | light-dark(#dfe3eb, #2a3140) |
--i-input-active-color-background | light-dark(var(--i-color-white), #1a1f28) |
--i-input-active-color-border | color-mix(in oklab, var(--i-color-primary), var(--i-color-ink) 10%) |
--i-input-focus-color-outline | color-mix(in oklab, var(--i-color-primary), var(--i-color-ink) 40%) |
--i-input-button-focus-color-outline | var(--i-input-focus-color-outline) |
--i-input-invalid-color-borderDerived from the danger and success colors, like the state icons | var(--i-color-danger) |
--i-input-invalid-active-color-border | color-mix(in oklab, var(--i-color-danger), var(--i-color-ink) 15%) |
--i-input-invalid-focus-color-outline | var(--i-input-invalid-active-color-border) |
--i-input-valid-color-border | color-mix(in oklab, var(--i-color-success), var(--i-color-ink) 15%) |
--i-input-valid-active-color-border | color-mix(in oklab, var(--i-color-success), var(--i-color-ink) 30%) |
--i-input-valid-focus-color-outline | var(--i-input-valid-active-color-border) |