Skip to content

Signal

Foundations

Theming

Light and dark themes, color palettes, named themes such as 8-bit, the theme switch, and overriding a component on one element.

Every color token has a light and a dark value. The CSS system switches on the root: by default it follows prefers-color-scheme, and data-theme="light" or data-theme="dark" on <html> forces one. .theme-light and .theme-dark pin a subtree, which is how the live examples on these pages show both themes side by side.

.theme-light

Muted text on the light card.

.theme-dark

Muted text on the dark card.

The theme switch

/site/site.js applies the stored preference (Auto, Light, Dark or Custom) and exposes window.ChiTransitSite; /site/theme.js applies it before first paint:

ChiTransitSite.preference()      // "system" | "light" | "dark", persisted per browser; "custom", this tab only
ChiTransitSite.effective()       // "light" | "dark"
ChiTransitSite.setPreference(p)  // change and persist
ChiTransitSite.palette()         // the custom palette's [background, text, accent], or null
ChiTransitSite.setPalette(seeds) // apply a palette and select Custom (needs /site/palette.js)
ChiTransitSite.onChange(fn)      // fn({ preference, effective }) after every change

Load /site/theme.js synchronously in <head> and /site/site.js with defer after it. Any .site-theme [data-theme-value] button is kept in sync with aria-pressed; the switch in this site's header is a segmented control wired that way.

Color palettes

A palette recolors Signal from three colors: background, text and accent. palette.js derives every other surface, text and accent token from them and applies the result to <html>. Presets live in tokens/tokens.json (palettes); riders can also pick their own three colors. On this site, choose Custom in the header; the palette lasts for the browser tab.

  • The background decides the base theme: a light background builds on Light, a dark one on Dark. Line, chart and map colors keep that theme's values.
  • Cards, hairlines, inactive and muted text are mixes of text into background; the accent tint is the accent mixed into background; the label on the accent is whichever of background or text reads better.
  • Text and accent are the rider's choice: they are checked against 4.5:1 and reported, never changed.
  • Muted text and the status colors (Due, Delayed, Alert text, Favorite text, Highlight) keep their meaning and are moved toward the text color until they reach 4.5:1 on background and card.
  • Every preset passes every check; tests/palette.test.mjs enforces it.

On the web, load @chitransit/signal/palette.js (a classic script) after chitransit.css:

SignalPalette.presets             // [{ name, label, seeds: [background, text, accent] }]
SignalPalette.derive(seeds)       // { mode, vars, checks, adjusted }
SignalPalette.apply(root, seeds)  // set the derived properties and data-theme on root; null clears

Named themes

A named theme goes further than a palette: it can change the font, radii, shadows and motion as well as colors. Themes live in tokens/tokens.json (themes) and are selected with data-theme="<id>" on <html>. On this site, choose Custom in the header, then a theme.

  • A theme starts from its base theme (light or dark) and overrides tokens by name; go generate rejects a name that doesn't exist.
  • Every text color, as the theme resolves it, must reach 4.5:1 on every text surface; go test enforces it.
  • Surfaces that can carry an outline read shadow.frame through their frame component token: card, button, segmented control, input and select, toast, error state and table. It is invisible unless a theme sets it.
  • Fonts a theme names ship in fonts/ with their licenses and are copied next to the CSS (fonts/); a face can be limited to some characters, such as digits.
  • site.js also sets data-scheme="light" or "dark", the base of whatever is showing. Style dark-only assets (logos, mockup art) with [data-scheme="dark"] as well as [data-theme="dark"] so they follow a dark-based theme.
  • Line colors keep the base theme's values. The line toggle's shape doesn't change yet.
"themes": [{
  "id": "8bit", "label": "8-bit", "base": "dark",
  "colors": { "paper": "#0B0B1E", … },
  "font": { "css": "\"Signal Pixel\", …" },
  "fontFaces": [{ "family": "Signal Pixel", "file": "jersey-15.woff2", … }],
  "radius": { "card": 0, … },
  "shadows": { "frame": "0 0 0 2px var(--line),4px 4px 0 2px #000", … },
  "motion": { "detail": "steps(4,end)" }
}]

Overriding a component

Each component reads its token behind an override: var(--button-radius, var(--ct-button-radius)). Change the token in tokens/components.tokens.json to restyle every instance, or set the property without the ct- prefix on one element or subtree:

.checkout .ct-button { --button-radius: var(--radius-pill); }

The tokens and base styles sit in cascade layers (ct.tokens, ct.base), so any unlayered page rule wins over them without !important.

Surface roles

Two roles decide what every surface is drawn with. They live in tokens/tokens.json (surfaces); a palette or theme recolors their fallback colors, never the roles.

  • chrome, the control layer: sheets, the landscape sidebar, the tab bar, toolbars and the Live Tracking card. React Native draws its fallback color; an iOS app may use the system's own glass on its native sheets, bars and toolbar items.
  • cardSurface, content inside chrome: arrival rows, stop cards and the direction control. A system material, or flat for the card color. It is flat today; choosing a material changes only this token's material.
  • Glass only in the control layer, materials for content: glass never sits on glass. A control inside chrome (the sidebar's header buttons) is drawn solid, not as glass. go test rejects a content role set to glass.
  • The web and exports draw each role's fallback color: var(--chrome) is Surface and var(--card-surface) is Card.
  • Reduce Transparency and Increase Contrast come from the system glass and materials.

React Native

The Signal provider resolves the same tokens, named themes and palettes for React Native and react-native-web. See React Native. Native extension targets copy standalone tokens.