VB Design System

<accessibility-specimen>

WCAG contrast-ratio table and accessibility checklist web component for design-system docs. Computes AA/AAA pass/fail badges from authored foreground/background color pairs.

Overview

The <accessibility-specimen> component renders a WCAG 2.x contrast-ratio table from authored foreground/background color pairs, or an accessibility checklist from an authored list. It computes relative luminance and contrast ratio client-side and shows AA / AA Large / AAA / AAA Large pass-fail badges per pair — no design-token dependency, so it works with any color values.

Attributes

Attribute Type Default Description
type string contrast Rendering mode: contrast (color-pair table) or checklist (status list).

Authoring Contrast Pairs

In contrast mode (the default), author direct <button> children with data-fg / data-bg / optional data-label. The component replaces them with a table — one row per pair, each with a live sample, the computed ratio, and pass/fail badges for AA, AA Large, AAA, and AAA Large thresholds.

Child attribute On Required Description
data-fg button Yes Foreground color (hex, rgb(), or named CSS color).
data-bg button Yes Background color (hex, rgb(), or named CSS color).
data-label button No Display label for the pair. Defaults to the button's text content.

Checklist Mode

Set type="checklist" and author a <ul> of <li data-status="pass|fail|warn|na"> items. The component normalizes the list styling and prepends a status icon (with a screen-reader-only label) per item.

  • Form inputs have associated labels.
  • Focus indicators are visible at 2px width minimum.
  • Some images may be missing alt text.
  • Color contrast on muted text fails AA.
  • No videos in this component (captions N/A).
Child attribute On Description
data-status li pass, fail, warn, or na (default when omitted).

Reading the Badges

Ratios are computed per WCAG 2.x relative luminance. Thresholds: AA normal text ≥4.5:1, AA large text ≥3:1, AAA normal text ≥7:1, AAA large text ≥4.5:1. A pair that fails to parse (unsupported color syntax) shows ? for the ratio and fails every badge.

Accessibility

  • Contrast table uses semantic <table> markup with <th scope="col"> / <th scope="row">, so screen readers can navigate rows and columns.
  • Pass/fail badges carry an explicit aria-label ("Pass" / "Fail") — they never rely on the check/cross glyph alone.
  • Checklist items get a screen-reader-only status label (e.g. "Warning: ") prepended before the item text, in addition to the visual icon.
  • The component itself doesn't judge your page's actual colors — it's a documentation aid. Always verify real rendered text against these thresholds, not just documented token pairs.