本文へ移動
cccskills
無料GitHub で公開

wcag-color-contrast

Reference for WCAG 2.2 color-contrast conformance - covers SC 1.4.3 Contrast (Minimum, AA), 1.4.6 Contrast (Enhanced, AAA), 1.4.11 Non-text Contrast (AA), and 1.4.13 Content on Hover or Focus (AA) - with the canonical contrast ratios (4.5:1 normal text, 3:1 large text and UI components), measurement formula references, and bulk design-token checking patterns. Use when designing a color palette, reviewing a component for accessibility, or auditing existing CSS for contrast violations.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qaスター 13(GitHub 13 + cccskills 0)

実行スコア 未検証

インストール方法を見る

含まれるファイル(2)

  • SKILL.md9.4 KB
  • .tessl-plugin/plugin.json623 B

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

wcag-color-contrast

Overview

WCAG 2.2 specifies four color-contrast Success Criteria (wcag22):

SCLevelWhat it covers
1.4.3AAText contrast minimums - 4.5:1 normal, 3:1 large.
1.4.6AAAEnhanced text contrast - 7:1 normal, 4.5:1 large.
1.4.11AANon-text contrast - UI components and graphics - 3:1.
1.4.13AAContent on Hover/Focus - keyboard-dismissable, hoverable, persistent.

Large text per WCAG 2.2 (wcag22): 18pt+ regular OR 14pt+ bold (24px / 18.66px in browsers default; 19px+ if bold).

When to use

  • Designing a new color palette / design tokens.
  • Reviewing a component's CSS for contrast violations.
  • Setting up bulk-checking of design tokens via tooling.
  • Authoring per-component a11y checklists (paired with screen-reader-test-author references/wcag-checklist.md).
  • Configuring per-rule severity in axe-a11y.

Contrast ratios

Text (SC 1.4.3 - Level AA)

Text sizeRequired ratio
Normal text (<18pt regular, <14pt bold)4.5:1
Large text (≥18pt regular OR ≥14pt bold)3:1

Exceptions per wcag22:

  • Pure decoration (text in a logo, "lorem ipsum" filler).
  • Inactive UI elements (disabled buttons - though the disabled state should still have visible-but-low-contrast text).
  • Logotypes - brand text within a logo.
  • Incidental text (text within an image of running text where the image isn't an essential conveyance of information).

Text (SC 1.4.6 - Level AAA)

The enhanced version doubles down: 7:1 normal, 4.5:1 large. Use this for accessibility-first products (educational platforms, public-sector services).

UI components and graphics (SC 1.4.11 - Level AA, NEW in 2.1)

Visual presentation of UI components and graphical objects must have 3:1 contrast against adjacent colors. This applies to:

  • Form input borders.
  • Focus indicators (per wcag-keyboard-navigation SC 2.4.7).
  • Icon buttons that don't have text labels.
  • Visual state indicators (toggle switches, checkboxes).
  • Required-field indicators that rely on color alone.

Content on Hover or Focus (SC 1.4.13 - Level AA)

Tooltips, dropdowns, and other content that appears on hover/focus must satisfy three conditions:

ConditionMeaning
DismissableUser can dismiss the additional content without moving pointer or focus (typically: Esc key).
HoverableIf the content appears on hover, the user can move the pointer onto the additional content without dismissing it.
PersistentThe additional content remains visible until the user dismisses it, hover/focus moves elsewhere, OR the information is no longer valid.

Most "tooltip" libraries fail one of these - typically Hoverable (pointer leaves trigger → tooltip dismisses → can't read it).

Measuring contrast

The WCAG contrast formula uses relative luminance (per wcag22 formula):

ratio = (L1 + 0.05) / (L2 + 0.05)

where L1 is the relative luminance of the lighter color and L2 of the darker. Ratios run from 1:1 (identical colors) to 21:1 (black on white).

You don't compute it manually - use a tool:

ToolNotes
WebAIM Contrast Checkerhttps://webaim.org/resources/contrastchecker/
Chrome DevToolsElement panel → Styles → color swatch → Contrast.
Figma plugins (Stark, Able)Inline check during design.
polished (npm) getContrast()Programmatic check in tests / lint rules.
axe-coreReports all on-screen contrast violations during a scan (axe-a11y).

Common ratios for canonical color pairings

Foreground / backgroundRatioNotes
#000000 on #FFFFFF21:1Maximum.
#FFFFFF on #00000021:1Reversed; same.
#767676 on #FFFFFF4.54:1Just passes 4.5:1.
#999999 on #FFFFFF2.85:1Fails AA normal text.
#0000EE (default link) on #FFFFFF8.59:1Passes AAA.

The "just-passes" boundary #767676 is a design pitfall - small font-rendering shifts on Windows ClearType can drop the perceived contrast below 4.5:1. Aim for ≥5:1 in practice.

Design token bulk checking

When the project has a design-token system (e.g. --color-text-primary: #1a1a1a), check token combinations en masse:

// scripts/check-contrast.js
const { getContrast } = require('polished');

const tokens = require('../tokens/colors.json');

const TEXT_PAIRS = [
  ['--color-text-primary', '--color-bg-default'],
  ['--color-text-secondary', '--color-bg-default'],
  ['--color-text-on-primary', '--color-bg-primary'],
  ['--color-link', '--color-bg-default'],
  ['--color-error', '--color-bg-default'],
];

const violations = [];
for (const [fg, bg] of TEXT_PAIRS) {
  const ratio = getContrast(tokens[fg], tokens[bg]);
  if (ratio < 4.5) {
    violations.push({ fg, bg, ratio: ratio.toFixed(2) });
  }
}

if (violations.length > 0) {
  console.error('Contrast violations:', violations);
  process.exit(1);
}

Wire into CI per a11y-violation-gate.

Common failures

PatternWhy it failsFix
color: #999 on white2.85:1 - fails AA.Darken to #767676 or darker.
Placeholder text in #aaaSame problem; placeholders are still text.Match the disabled-text color used elsewhere; ≥4.5:1 OR remove placeholder reliance and use floating labels.
White text on a brand-color buttonMany brand colors fail 4.5:1 with pure white.Darken the brand color OR add a darker tone for hover/active.
Focus ring #aaa on a #fff background2.85:1 - fails SC 1.4.11 (3:1).Use #666 or darker; or add a 1px outline that contrasts both ways.
Required-field marker via red-only *Red on white: ~4:1 - passes - but also color-alone (SC 1.4.1).Add a non-color cue: text "(required)" or an icon.
Disabled button text contrast below 3:1Even disabled text should be perceivable.~3:1 minimum on disabled; test with users for whether this matches expected interactivity.

Anti-patterns

Anti-patternWhy it failsFix
Designing in pure RGB (#3CB371) without a CIELab-aware toolTwo colors with the same RGB distance can have wildly different luminance ratios.Use a tool that computes WCAG-formula ratio.
Asserting contrast at the token level onlyTokens are correct but actual rendered contrast differs (transparency, pseudo-elements, dark mode).Bulk-check token pairs AND scan the rendered DOM via axe-core.
Single-mode token checkLight-mode pairs pass but dark-mode pairs fail.Check every theme variant.
Using opacity / rgba for subtle textThe browser blends; perceived contrast against the background is whatever the blended result computes to - often below threshold.Compute the blended color first; check that.

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Builds a CI gate that fails the build on **new** WCAG / a11y violations introduced by a PR while grandfathering pre-existing violations on a per-rule / per-page baseline. Aggregates verdicts from axe-core / pa11y / Lighthouse a11y / WAVE / IBM Equal Access scans. Use when a project has accumulated a11y debt and a strict "zero violations" gate would block every PR - the ratchet pattern lets the team ship while preventing regressions.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Workflow skill that builds an A/B-test validity checklist from an experiment proposal, walking the canonical design-correctness gates - pre-registered OEC/power/guardrails, randomization unit + SRM check, assignment integrity, telemetry, peeking discipline, novelty/primacy, post-experiment SRM re-check - into a per-experiment checklist + sign-off form. Use when launching, auditing, or governing an experiment. For pitfall mechanics (guardrails, peeking) see experiment-results-interpreter's references; to read an already-valid result use experiment-results-interpreter; for per-SDK harness tests use experiment-sdk-testing - this gates DESIGN, not SDK code.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

The single install-flow skill: the reference contract for the PWA install flow (installability gate fields, `beforeinstallprompt` handshake, per-platform paths - Android WebAPK / iOS Share menu / Firefox no-op - and the `display-mode` post-install signal, in references/install-flow-reference.md) plus the build-an-X workflow that emits the Add-to-Home-Screen suite. Walks the four-stage timeline, emitting one test per gate cell per [web.dev/articles/install-criteria][install-criteria], the deferred-prompt → `prompt()` → `userChoice` chain per [web.dev/articles/customize-install][customize-install], the iOS Safari manual-metadata branch (`apple-touch-icon`) per [web.dev/learn/pwa/installation][learn-pwa], and the post-install `(display-mode: standalone)` MQ assertion. Output: a Playwright spec with per-stage cells plus a coverage matrix. Use when a PWA's manifest, icons, or install handler change, when install conversion drops at an unknown stage, or when triaging a flaky install assertion.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Build-an-X workflow that uses an LLM to map existing tests to spec sections - given a spec doc + the test suite, the LLM identifies which tests cover which sections, surfaces uncovered sections (gap), and recommends specific tests to add. Output is a coverage matrix per spec ID. Scope is mapping tests that already exist and naming the gaps, not authoring tests for new acceptance criteria. Use when a spec doc and a test suite both exist but nobody can say which requirements are actually covered - before a release sign-off, an audit, or a decision about where to spend the next round of test effort.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Generates tests from natural-language specs (acceptance criteria, user stories, requirements) using an LLM, with confidence scoring per test case (LLM self-assessment plus heuristics: assertion quality, naming, completeness), batching uncertain cases for human review, and integration with the team's existing test framework. Use when the user asks to generate unit tests from acceptance criteria, convert user stories to test cases, automate test creation from requirements, or augment a spec-driven test suite with AI-generated stubs that are then curated before merge.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

Configures Allure Report (test-runner adapter install, `allure-results` directory wiring, `categories.json` for failure classification, `history-trend.json` retention via the copy-history-between-runs pattern), runs the Allure CLI to convert `allure-results` to a static HTML site, and uploads the report as a CI artifact. Use when the team needs richer test reporting than JUnit XML - step-level attachments, per-test history, retry tracking, and severity / epic / feature labeling across framework-agnostic adapters (pytest, Jest, JUnit, TestNG, NUnit, Mocha). As a rich static HTML report generator, it is the open-source alternative to the sunset ExtentReports (JVM/.NET per-test HTML narrative); for hosted cross-run flakiness analytics rather than a static per-run report use currents-integration.

日本語の概要は準備中です。原文の説明を表示しています。

testland/qa132026年10月20日 更新

testland のスキルをすべて見る

このスキルの問題を報告する