<breakpoint-specimen>
Responsive breakpoint visualization web component. Renders a ruler of viewport breakpoints with a live width readout and a moving cursor for the active breakpoint.
Overview
The <breakpoint-specimen> component reads --bp-* breakpoint tokens from computed styles and renders a ruler of viewport breakpoints, a live numeric width readout, and a moving cursor marking the current position. The active breakpoint is called out both on the ruler and in the readout.
<breakpoint-specimen></breakpoint-specimen>
Resize the browser window to see the width readout, cursor, and active-breakpoint highlight update live.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
tokens |
string | sm,md,lg,xl |
Comma-separated breakpoint names to display |
prefix |
string | --bp- |
CSS custom property prefix for token lookup |
label |
string | - | Optional heading label above the ruler |
data-observe |
string | - | CSS selector of a container to track instead of the viewport (container-query mode, JS-only) |
Custom Subset
Show only the breakpoints you need, and add a heading label.
<breakpoint-specimen tokens="sm,md,lg" label="Core breakpoints"></breakpoint-specimen>
Container Mode
Set data-observe to a CSS selector to track a specific element's width (via ResizeObserver) instead of the viewport — useful for documenting a breakpoint scheme that applies to a resizable panel or preview frame rather than the whole window.
<breakpoint-specimen data-observe="#preview-frame"></breakpoint-specimen>
Progressive Enhancement
The component follows three layers of enhancement:
- HTML — a semantic
<dl>of breakpoint name → value remains readable without JS or CSS. - CSS — pure-CSS active-row highlighting via
@mediarules pulls the matching token into a callout, no JS required for the "which breakpoint is active" cue (viewport mode only). - JS — adds the live numeric width readout and the moving cursor on the ruler, plus container-query mode (
data-observe).
<breakpoint-specimen> <dl> <dt>sm</dt><dd>37.5rem (600px) and up</dd> <dt>md</dt><dd>48rem (768px) and up</dd> <dt>lg</dt><dd>64rem (1024px) and up</dd> <dt>xl</dt><dd>87.5rem (1400px) and up</dd> </dl></breakpoint-specimen>
Theme-Aware
The component reads live computed --bp-* values, so a theme that redefines breakpoint tokens updates the ruler automatically. Pair with <spacing-specimen> and <type-specimen> for complete design system documentation pages.