ComponentsInput
Input
atomThe text field and its label/hint/error anatomy — the base of every form.
New contact
Add someone to your address book.
Recipe CSS
This is the exact CSS your kit ships for Input — token-driven, so it re-themes with every knob. Get it (and the rest) from the configurator's Use kit panel.
/* === Form ===
* Inputs follow Stature: Compact = 32px (Linear/Cursor feel), Balanced = 40px
* (shadcn default), Bold = 48px (consumer / mobile-first). Horizontal padding
* stays radius-aware so pill-radius inputs get enough room past the curve. */
.in {
display: flex;
align-items: center;
min-height: var(--k-in-h-default, 40px);
padding-block: 0;
/* Horizontal padding floor 12px (Linear / shadcn-equiv) + radius-aware
* scaling so rounded inputs still keep the label clear of the curve. */
padding-inline: max(var(--k-s-12), calc(var(--k-radius-md) * 0.6));
/* Surface treatment, token-driven (Outlined/Filled/Plain — one rule, three
* looks). --k-field-radius is 0 in Plain (the underline is a straight line).
* --k-field-bg is transparent in Plain. The border is set on all sides via
* --k-field-border-color (input-border in Outlined, transparent in Filled +
* Plain) and the BOTTOM is overridden to --k-field-underline-color — so Plain
* shows only an underline while Outlined gets a full box. Border (faint→strong)
* still feeds --k-input-border, so it tunes the line in every mode. */
border-radius: var(--k-in-radius, var(--k-field-radius));
background: var(--k-in-bg, var(--k-field-bg));
border: var(--k-bw, 1px) solid var(--k-field-border-color);
border-bottom-color: var(--k-field-underline-color);
color: var(--k-fg);
width: 100%;
font-size: var(--k-type-small);
font-family: var(--k-font-body);
/* Stable text positioning across focus states — see wrapper-fields
* rule for full rationale. Chrome on macOS sub-pixel re-renders text
* when input becomes focused; geometricPrecision disables that. */
text-rendering: geometricPrecision;
}
/* Sunken filled-field signature: every input sits on --k-input-bg (the
* brand-tinted recessed neutral), the SAME fill as .select-trigger / .taginput /
* .otp__slot — so all field types read as one family. Was --k-surface-2 here,
* which silently overrode the --k-input-bg set above (this rule comes later in
* source order) and made plain inputs/textarea lighter than selects. The fill is
* elevation-coupled (tracks Neutrals/Emphasis), giving the "pressed-in" depth
* without a heavy inset shadow. Pairs with the tactile button shadow — same row,
* opposite depth. */
.in {
background: var(--k-field-bg);
/* Inputs sit flat on the surface — no inset pressed shadow. shadcn
* pattern: emphasis lives in the focus halo, not in a default inner
* shadow that competes with body text. */
box-shadow: none;
transition:
border-color var(--k-dur-fast, 110ms) var(--k-ease, ease),
box-shadow var(--k-dur-fast, 110ms) var(--k-ease, ease),
background var(--k-dur-fast, 110ms) var(--k-ease, ease);
}
/* Hover: the box edge darkens in Outlined/Filled; in Plain only the underline
* darkens (--k-field-hover-edge is transparent there, so no box appears). */
.in:hover:not(:focus):not(:disabled) { border-color: var(--k-field-hover-edge); border-bottom-color: var(--k-state-border, var(--k-fg-faint)); }
/* Disabled — apply to .in itself and to wrapper-style inputs (numinput,
* pwinput, etc) when the trigger has [aria-disabled] or contains a
* disabled field. Opacity + no-pointer is the shadcn standard. */
.in:disabled,
.in[aria-disabled="true"] {
opacity: var(--k-disabled-opacity, 0.55);
cursor: not-allowed;
background: var(--k-disabled-bg, var(--k-surface-sunken));
color: var(--k-disabled-fg, var(--k-fg-muted));
pointer-events: none;
}
/* Read-only — distinct from disabled: still focusable + text-selectable, just
* not editable. Drops the sunken input fill so it reads as "display value, not
* an input well", mutes the text and shows a default cursor. Targets the
* [readonly] ATTRIBUTE (not :read-only, which also matches the .in wrapper
* DIVs — divs are always read-only). Was a real defect: read-only looked
* identical to an editable field. */
input.in[readonly],
textarea.in[readonly] {
background: var(--k-surface);
color: var(--k-fg-muted);
cursor: default;
box-shadow: none;
}
/* Focus: border + halo SAME hue, different alphas → reads as ONE
* softening ring (shadcn pattern). Border becomes --k-ring (full alpha),
* halo is --k-ring-halo (28% alpha of same color). The match is critical:
* default border is computed from --k-input-border (neutral grey) which
* has a different hue than --k-ring (brand primary) — if we leave border
* neutral and only paint a brand halo, eye reads "two rings". Same hue
* blend is what makes shadcn focus look unified.
*
* For validation states (invalid/success/warning), compound selectors
* lower in the file override border+halo to the state color — same
* unified-hue trick applies per state.
*
* HCM fallback: transparent outline browsers auto-promote to system
* Highlight color in forced-colors mode. WCAG 2.4.7 + 2.4.13 compliant. */
.in:focus,
.in:focus-within {
/* :focus fires when .in is a direct input (Email, Notes textarea, etc).
* :focus-within fires when .in is a WRAPPER like .in.in--inline that
* holds an inner <input> (Search field with icon). Combining both
* means every .in variant gets the same focus treatment — single
* coherent ring across all input shapes. */
outline: 2px solid transparent;
outline-offset: 2px;
/* Box modes light the whole edge to --k-ring; Plain keeps top/sides
* transparent (--k-field-focus-edge) and only brand-colours the underline —
* the affordance lives in the focus state (Material-style) + the halo. */
border-color: var(--k-field-focus-edge);
border-bottom-color: var(--k-ring);
box-shadow: 0 0 0 var(--k-ring-w) var(--k-ring-halo);
}
/* Bulletproof focus signal — the SINGLE source of focus on a field is its
* own border+halo, NEVER the global solid :focus-visible outline (line ~56).
* `.in:focus` above sets a transparent outline, but it's only EQUAL
* specificity to the global rule, so under real keyboard focus (where
* :focus-visible matches) the cascade is decided by source order alone —
* fragile. This rule is higher specificity (.cockpit-preview prefix → 0,3,0)
* so it ALWAYS wins, killing the blue outline that otherwise:
* • doubles up on a plain .in (heavier ring than wrapper fields), and
* • clashes on validation states (green/red border + a stray blue ring).
* Mirrors the wrapper-child suppression at line ~4574 — same bug, same cure,
* now applied to every standalone field shape. Validation border+halo come
* from the (0,3,0) state rules above; this only touches `outline`, no clash. */
.cockpit-preview .in:focus-visible,
.cockpit-preview .select-trigger:focus-visible,
.cockpit-preview .otp__slot:focus-visible {
/* OTP slots are real <input>s — they own the soft border+halo via
* `.otp__slot:focus`, so suppress the global solid :focus-visible outline
* too (else keyboard focus paints BOTH = the default solid ring on top). */
outline: 2px solid transparent;
outline-offset: 2px;
}
.in--inline {
display: flex;
align-items: center;
gap: var(--k-s-6);
/* No padding-block: the input STRETCHES to the wrapper's full height instead.
* With vertical wrapper padding, the input collapses to ~line-height and its
* overflow:clip shaves the text caret (the "short caret" bug). Letting the
* input fill the box gives the caret the same room a standalone .in input has. */
padding-block: 0;
padding-inline: max(var(--k-s-10), calc(var(--k-radius-md) * 0.5));
}
/* align-self: stretch → input fills the wrapper height (the icon stays centred via
* the wrapper's align-items:center); native input vertical-centering keeps the text
* centred, and the now-tall box stops overflow:clip from clipping the caret. */
.in--inline input { background: transparent; border: 0; outline: 0; flex: 1; align-self: stretch; color: inherit; font: inherit; padding: 0; text-rendering: geometricPrecision; }
.in--inline input:focus, .in--inline input:focus-visible { outline: 0; }
/* Search inputs are type="search" for correct semantics (Enter-to-search,
role=searchbox for screen readers). Reset the native `searchfield` look on
the field ITSELF — otherwise WebKit renders it as a rounded native field that
shortens + clips the text caret at its invisible rounded inner edge. Plus
suppress the native clear "×"/decoration so it never doubles our ghost clear. */
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
/* Textarea overrides .in's padding-block: 0 (which works for align-items:
* center on single-line inputs but leaves textarea text glued to the top).
* 12px aligns to the 4px grid (3×4) AND matches the y-position of a
* single-line input's text baseline: a 40px-tall .in with 18px line-height
* lands its text top at (40-18)/2 = 11px from the box top, so 12px reads
* as continuous with the inputs above and below it in a form column.
* Explicit line-height: 1.5 keeps multi-line spacing on the same rhythm. */
.tx {
min-height: 78px;
padding-block: var(--k-s-12);
line-height: 1.5;
resize: vertical;
}
.lab {
display: flex;
flex-direction: column;
gap: var(--k-s-4);
font-size: var(--k-type-small);
color: var(--k-fg);
}
.lab > span:first-child {
font-size: var(--k-type-eyebrow);
color: var(--k-fg-muted);
/* Form labels inherit UI weight; case follows the meta-label tier (labelCase) */
font-weight: var(--k-ui-weight, 500);
text-transform: var(--k-label-transform, none);
letter-spacing: var(--k-label-tracking, 0);
}
/* === FormField (.field) — the full form-row contract: label + required marker +
* control + hint + error, wired for a11y (aria-describedby → hint/error ids,
* aria-invalid on the control). This is shadcn's FormItem / FormLabel /
* FormDescription / FormMessage collapsed into one primitive so a labelled,
* described, validated field is rebuildable from the export — the #1 systemic
* gap before. (.lab stays the lightweight label-over-control; .field is the full
* contract: reach for .field when a row needs a hint, an error or a required *.) */
.field { display: flex; flex-direction: column; gap: var(--k-s-6); }
.field__label { display: inline-flex; align-items: center; gap: var(--k-s-4); font-size: var(--k-type-small); font-weight: var(--k-weight-medium); color: var(--k-fg); }
/* Required marker — a danger-toned asterisk after the label text. */
.field__req { color: var(--k-danger); }
.field__hint { font-size: var(--k-type-caption); color: var(--k-fg-muted); line-height: 1.4; }
/* Error message — only render when the control is invalid; pairs with
* aria-invalid="true" + aria-describedby on the control. */
.field__error { display: inline-flex; align-items: center; gap: var(--k-s-4); font-size: var(--k-type-caption); color: var(--k-danger); line-height: 1.4; }
.check, .radio {
display: inline-flex;
align-items: center;
gap: var(--k-s-10);
font-size: var(--k-type-small);
cursor: pointer;
line-height: 1.4;
}
/* Custom checkbox + radio — appearance: none kills the platform UI, we draw
our own 16px square/circle. Uses --k-input-border so it visually matches
form inputs, and --k-primary for the checked state. */
.check input[type="checkbox"], .radio input[type="radio"] {
appearance: none;
-webkit-appearance: none;
width: 16px;
height: 16px;
border: max(1.5px, var(--k-bw)) solid var(--k-input-border);
background: var(--k-surface);
display: inline-grid;
place-items: center;
position: relative;
cursor: pointer;
margin: 0;
padding: 0;
flex: none;
transition: background var(--k-dur-fast, 120ms) var(--k-ease, ease), border-color var(--k-dur-fast, 120ms) var(--k-ease, ease);
}
/* A checkbox is a slightly-rounded SQUARE, never a near-circle. Cap the corner
* at 4px (≈ shadcn's 25% on a 16px box) so it still responds to Box radius
* (0 at None) but never rounds off into radio-button territory at Soft/Round. */
.check input[type="checkbox"] { border-radius: min(var(--k-radius-sm), 4px); }
.radio input[type="radio"] { border-radius: 50%; }
.check input[type="checkbox"]:hover,
.radio input[type="radio"]:hover { border-color: var(--k-fg-faint); }
.check input[type="checkbox"]:focus-visible,
.radio input[type="radio"]:focus-visible {
outline: 2px solid var(--k-ring-soft);
outline-offset: 1px;
}
.check input[type="checkbox"]:checked {
background: var(--k-primary);
border-color: var(--k-primary);
}
.check input[type="checkbox"]:checked::after {
content: '';
/* Absolute so the checkmark is OUT of flow — an in-flow grid item shifts the
box's baseline by ~1.5px the moment it appears, making the checkbox visibly
jump on check. Out of flow → zero layout impact, no jump. Centred via
top/left 50% + translate, then the same optical nudge as before. */
position: absolute;
top: 50%;
left: 50%;
width: 9px;
height: 5px;
border-left: 1.5px solid var(--k-primary-fg);
border-bottom: 1.5px solid var(--k-primary-fg);
transform: translate(-50%, -50%) rotate(-45deg) translate(1px, -1px);
}
/* Indeterminate — the "some-but-not-all selected" state (set via the .indeterminate
* DOM property in JS; there is no HTML attribute). Filled like :checked but with a
* horizontal dash instead of the tick — the standard table select-all glyph. */
.check input[type="checkbox"]:indeterminate {
background: var(--k-primary);
border-color: var(--k-primary);
}
.check input[type="checkbox"]:indeterminate::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 9px;
height: 0;
border-top: 1.5px solid var(--k-primary-fg);
transform: translate(-50%, -50%);
}
/* Disabled checkbox/radio — muted + not-allowed, the :checked tick still shows
* (a disabled-but-checked row reads as "locked on", not empty). */
.check input:disabled,
.radio input:disabled {
opacity: var(--k-disabled-opacity, 0.55);
cursor: not-allowed;
}
.radio input[type="radio"]:checked {
border-color: var(--k-primary);
}
.radio input[type="radio"]:checked::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--k-primary);
transform: translate(-50%, -50%);
}
/* === Input add-ons + inset / overlapping labels (Tailwind input groups) ====
* Four field embellishments that all build on .in:
* .in-group a segmented field — a filled add-on butts against the input
* (https:// prefix, .com suffix). Fused edges (the .btn-group
* idiom); the input keeps its focus halo, lifted above neighbours.
* .in__affix an inline unit INSIDE the field ($ … USD), as a muted span in
* an .in--inline wrapper.
* .in--inset the label lives inside the field at the top, input below.
* .in-field + .in__overlap the label straddles the top border in a surface chip. */
.in-group { display: flex; align-items: stretch; width: 100%; }
.in-group > * { border-radius: 0; }
.in-group > *:not(:first-child) { margin-left: -1px; }
.in-group > *:first-child { border-top-left-radius: var(--k-in-radius, var(--k-radius-md)); border-bottom-left-radius: var(--k-in-radius, var(--k-radius-md)); }
.in-group > *:last-child { border-top-right-radius: var(--k-in-radius, var(--k-radius-md)); border-bottom-right-radius: var(--k-in-radius, var(--k-radius-md)); }
.in-group > .in { width: auto; flex: 1; }
.in-group > .in:focus, .in-group > .in:focus-within { position: relative; z-index: 1; }
.in-group__addon {
display: inline-flex; align-items: center; white-space: nowrap; flex: none;
padding-inline: var(--k-s-10);
background: var(--k-surface-sunken); color: var(--k-fg-muted);
border: var(--k-bw, 1px) solid var(--k-input-border, var(--k-border));
font-size: var(--k-type-small);
}
.in__affix { color: var(--k-fg-muted); flex: none; user-select: none; }
.in--inset {
flex-direction: column; align-items: stretch; justify-content: center; gap: var(--k-s-2);
min-height: calc(var(--k-in-h-default, 40px) * 1.35); padding-block: var(--k-s-6);
}
.in--inset .in__label { font-size: var(--k-type-eyebrow); font-weight: var(--k-weight-medium); color: var(--k-fg-muted); }
.in--inset input { background: transparent; border: 0; outline: 0; padding: 0; font: inherit; color: inherit; width: 100%; }
.in-field { position: relative; }
.in__overlap {
position: absolute; top: 0; left: var(--k-s-8); transform: translateY(-50%);
padding: 0 var(--k-s-4); background: var(--k-surface); line-height: 1;
font-size: var(--k-type-eyebrow); font-weight: var(--k-weight-medium); color: var(--k-fg-muted);
}