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-searchCode
<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 property | Value | Alias | Resolves to |
|---|---|---|---|
--ct-input-background | var(--card) | {colors.card} | #EDEEF1 #1D232D |
--ct-input-background-hover | var(--card-hover) | {colors.cardHover} | #E4E6E9 #252B35 |
--ct-input-border | var(--muted) | {colors.muted} | #5B6472 #B0BACA |
--ct-input-border-invalid | var(--alert) | {colors.alert} | #C85414 #F08A4A |
--ct-input-color | var(--ink) | {colors.ink} | #101A2E #EEF1F6 |
--ct-input-color-placeholder | var(--muted) | {colors.muted} | #5B6472 #B0BACA |
--ct-input-error-color | var(--alert-text) | {colors.alertText} | #9C4007 #F7AA78 |
--ct-input-error-font-size | var(--fs-sub) | {type.sub} | 13 |
--ct-input-error-gap | var(--space-6) | {space.s6} | 6 pt |
--ct-input-error-glyph-color | var(--alert) | {colors.alert} | #C85414 #F08A4A |
--ct-input-font-size | var(--fs-body) | {type.body} | 16 |
--ct-input-frame | var(--shadow-frame) | {shadows.frame} | |
--ct-input-gap | var(--space-10) | {space.s10} | 10 pt |
--ct-input-height | var(--size-search-field) | {size.searchField} | 44 pt |
--ct-input-icon-size | var(--size-inline-glyph) | {size.inlineGlyph} | 18 pt |
--ct-input-label-color | var(--muted) | {colors.muted} | #5B6472 #B0BACA |
--ct-input-label-font-size | var(--fs-sub) | {type.sub} | 13 |
--ct-input-label-font-weight | var(--weight-semibold) | {weight.semibold} | 600 |
--ct-input-label-gap | var(--space-6) | {space.s6} | 6 pt |
--ct-input-padding-x | var(--space-12) | {space.s12} | 12 pt |
--ct-input-radius | var(--r-card) | {radius.card} | 12 pt |
Contract
Contract: components/search-field.yaml. States are drawn live by transit.js.
Loading the contract…
Contract: components/text-field.yaml. States are drawn live by transit.js.
Loading the contract…
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-inputin 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-searchfor 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 setaria-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-erroris linked witharia-describedby.