Skip to content

Signal

Components

Card grid

Responsive grids of cards, pairs and stat tiles.

Responsive grids of Cards: as many columns as fit, a two-up pair, or packed stat tiles.

Live example

The real classes from /site/chitransit.css in frames at phone, tablet and desktop widths, in the docs theme. The contract below shows each width in light and dark.

Phone · 390 × 760
Tablet · 768 × 900
Desktop · 1280 × 800

Code

<div class="ct-card-grid">
  <section class="ct-card">…</section>
  <section class="ct-card">…</section>
</div>
<div class="ct-card-grid ct-card-grid--pair">…</div>
<div class="ct-card-grid ct-card-grid--tiles">…</div>

Responsive behavior

ViewportLayout
> 760 wideColumns at least 300 wide (size.cardGridMinimum), 16 apart; pairs two up; tiles at least 130 wide.
≤ 760 wideCards in one column.
≤ 600 widePairs in one column. Tiles never collapse.

Tokens

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

Custom propertyValueAliasResolves to
--ct-card-grid-gapvar(--space-16){space.s16}16 pt
--ct-card-grid-gap-pairvar(--space-12){space.s12}12 pt
--ct-card-grid-gap-tilesvar(--space-8){space.s8}8 pt
--ct-card-grid-minvar(--size-card-grid-minimum){size.cardGridMinimum}300 pt
--ct-card-grid-min-tilesvar(--size-tile-grid-minimum){size.tileGridMinimum}130 pt

Variants

The default fits as many columns at least 300 wide as the width allows. --pair is two equal columns; --tiles packs small stat tiles and never collapses. Nothing else exists.

  • Cards of one kind, any number: the default.
  • Two cards that belong side by side: --pair.
  • Small stat tiles: --tiles.
<!-- Do -->
<div class="ct-card-grid ct-card-grid--pair">
  <section class="ct-card">…</section>
  <section class="ct-card">…</section>
</div>
<!-- Don't: a hand-set column count -->
<div class="ct-card-grid" style="grid-template-columns:repeat(3,1fr)">…</div>

Usage

Do

  • Keep cards in a grid the same kind and roughly the same height.

Don't

  • Don't rely on the grid for order; source order is reading order.

Accessibility

  • Give each card a heading; the grid itself is not announced.

Contract

Contract: components/card-grid.yaml. States are drawn live by transit.js.