Components
Filter segment
A labeled filter: an uppercase caption before a scrolling segmented control.
Live example
Rendered with the real classes from /site/chitransit.css, light (left) and dark (right).
Client
.ct-filter · .ct-filter-label · .ct-segmented--scrollCode
<div class="ct-filter"><span class="ct-filter-label" id="demo-filter-client">Client</span><div class="ct-segmented ct-segmented--scroll" role="radiogroup" aria-labelledby="demo-filter-client"><button role="radio" aria-checked="true" tabindex="0">All</button><button role="radio" aria-checked="false" tabindex="-1">iOS</button><button role="radio" aria-checked="false" tabindex="-1">Web</button><button role="radio" aria-checked="false" tabindex="-1">Widget</button><button role="radio" aria-checked="false" tabindex="-1">Untagged</button></div></div>
Tokens
From tokens/components.tokens.json. Override one instance by setting the property without the ct- prefix.
| Custom property | Value | Alias | Resolves to |
|---|---|---|---|
--ct-filter-gap | var(--space-8) | {space.s8} | 8 pt |
--ct-filter-label-color | var(--muted) | {colors.muted} | #5B6472 #B0BACA |
--ct-filter-label-font-size | var(--fs-cap) | {type.cap} | 12 |
--ct-filter-label-font-weight | var(--weight-semibold) | {weight.semibold} | 600 |
--ct-filter-label-tracking | .06em | ||
--ct-filter-segment-padding-x | var(--space-10) | {space.s10} | 10 pt |
Variants
One form; no variants. .ct-filter holds a .ct-filter-label and a .ct-segmented.ct-segmented--scroll radiogroup; add .ct-segmented--touch on phones. Nothing else exists.
<!-- Do -->
<div class="ct-filter">
<span class="ct-filter-label" id="filter-client">Client</span>
<div class="ct-segmented ct-segmented--scroll" role="radiogroup" aria-labelledby="filter-client">
<button role="radio" aria-checked="true" tabindex="0">All</button>
<button role="radio" aria-checked="false" tabindex="-1">iOS</button>
</div>
</div>
<!-- Don't: wrapping segments, and a caption the group doesn't point at -->
<div class="ct-filter">
<span class="ct-filter-label">Client</span>
<div class="ct-segmented" style="flex-wrap:wrap">…</div>
</div>
Usage
Do
- Use a filter segment to narrow a list or chart by one dimension (client, repository, response class).
- Put All first and select it by default.
- Let the page stack the caption above the control on phones (
flex-direction:columnon.ct-filter).
Don't
- Don't wrap the segments onto a second line; the control scrolls sideways instead.
- Don't use it to switch views; use a segmented control or tabs.
Accessibility
- Name the group with the caption:
aria-labelledbyon therole="radiogroup"pointing at.ct-filter-label. - Segments are
role="radio"; the current one carriesaria-checked="true"and is the only one in the Tab order. The arrow keys move and check, as on Segmented. - On phones add
.ct-segmented--touchfor 44pt segments.