Skip to content

Signal

Components

Input

Text inputs, selects and the search field (.ct-search with a leading glyph). Pair with .ct-field for a label.

Live example

Rendered with the real classes from /site/chitransit.css, light (left) and dark (right).

.ct-field · .ct-input
.ct-select
.ct-search

Code

<label class="ct-field"><span class="ct-field-label">Route</span><input class="ct-input" placeholder="22 Clark"></label>
<select class="ct-select" aria-label="Day"><option>Today</option></select>
<label class="ct-search"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><circle cx="11" cy="11" r="6.5"/><path d="M20 20l-4.2-4.2"/></svg><input placeholder="Search stops" aria-label="Search stops"></label>

Tokens

From tokens/components.tokens.json. Override one instance by setting the property without the ct- prefix.

Custom propertyValueAliasResolves to
--ct-input-backgroundvar(--card){colors.card}#EDEEF1 #1D232D
--ct-input-background-hovervar(--card-hover){colors.cardHover}#E4E6E9 #252B35
--ct-input-bordervar(--muted){colors.muted}#5B6472 #B0BACA
--ct-input-border-invalidvar(--alert){colors.alert}#C85414 #F08A4A
--ct-input-colorvar(--ink){colors.ink}#101A2E #EEF1F6
--ct-input-color-placeholdervar(--muted){colors.muted}#5B6472 #B0BACA
--ct-input-error-colorvar(--alert-text){colors.alertText}#9C4007 #F7AA78
--ct-input-error-font-sizevar(--fs-sub){type.sub}13
--ct-input-error-gapvar(--space-6){space.s6}6 pt
--ct-input-error-glyph-colorvar(--alert){colors.alert}#C85414 #F08A4A
--ct-input-font-sizevar(--fs-body){type.body}16
--ct-input-framevar(--shadow-frame){shadows.frame}
--ct-input-gapvar(--space-10){space.s10}10 pt
--ct-input-heightvar(--size-search-field){size.searchField}44 pt
--ct-input-icon-sizevar(--size-inline-glyph){size.inlineGlyph}18 pt
--ct-input-label-colorvar(--muted){colors.muted}#5B6472 #B0BACA
--ct-input-label-font-sizevar(--fs-sub){type.sub}13
--ct-input-label-font-weightvar(--weight-semibold){weight.semibold}600
--ct-input-label-gapvar(--space-6){space.s6}6 pt
--ct-input-padding-xvar(--space-12){space.s12}12 pt
--ct-input-radiusvar(--r-card){radius.card}12 pt

Contract

Contract: components/search-field.yaml. States are drawn live by transit.js.

Contract: components/text-field.yaml. States are drawn live by transit.js.

Variants

Three controls: .ct-input, .ct-select and .ct-search (a <label> around a glyph and a bare input). .ct-field stacks a label above one, with an optional .ct-field-error. aria-invalid="true" and disabled are the only states. Nothing else exists; there is no default, so pick by the data.

  • Free text: .ct-input in a .ct-field.
  • One choice from a fixed list: .ct-select.
  • Search: .ct-search.
<!-- Do -->
<label class="ct-field"><span class="ct-field-label">Route</span><input class="ct-input" placeholder="22 Clark"></label>
<!-- Don't: the placeholder as the only label -->
<input class="ct-input" placeholder="Route">

Usage

Do

  • Pair every input with a visible label in a .ct-field.
  • Use .ct-search for search, with its leading glyph. Build it as a <label> around the glyph and input, so a tap anywhere on it focuses the input.
  • Show an error under the field in a .ct-field-error (the alert glyph and the message) and set aria-invalid="true".

Don't

  • Don't use the placeholder as the only label.

Accessibility

  • Associate the label with for/id.
  • Use type="search" for search fields so assistive tech announces them.
  • Every field draws an edge of at least 3:1 on Surface and Card; an invalid one turns Alert, and its .ct-field-error is linked with aria-describedby.