HUB
Sign inSign up

nexfield/contrast

By nexfield

•Updated 5 days ago

WCAG 2.2 colour contrast checker CLI: ratio, AA/AAA, JSON, CI exit codes. By Nexfield Academy

Image
0

93

nexfield/contrast repository overview

⁠nexfield/contrast — WCAG colour contrast checker CLI

Check the contrast of two colours against WCAG 2.2 from the command line, in CI or in a design-token pipeline. Made by Nexfield Academy⁠, an online school of UX/UI, graphic and web design.

docker run --rm nexfield/contrast "#767676" "#ffffff"
# 4.54:1  AA text ✓  AA large ✓  AAA text ✗  AAA large ✓  UI ✓

⁠Usage

docker run --rm nexfield/contrast <text colour> <background colour> [--json]
  • Colours: #rgb, #rrggbb, #rrggbbaa, rgb(), hsl() (comma or space syntax), white, black.
  • Translucent colours are laid over the background before measuring.
  • --json prints a machine-readable result.
  • Exit code: 0 passes AA for normal text (4.5:1), 1 fails, 2 bad input — handy as a CI check.
docker run --rm nexfield/contrast "rgb(0 64 255)" white --json
# {"foreground":"rgb(0 64 255)","background":"white","ratio":6.6,"aaNormal":true,...}

⁠Thresholds

CheckAAAAA
Normal text4.5:17:1
Large text (24 px, or 18.66 px bold)3:14.5:1
Icons, borders, focus rings (WCAG 1.4.11)3:1—

The ratio is rounded down to two decimals before it is compared, so 4.49:1 never passes as 4.5:1.

⁠Other tools

Want to learn how designers choose accessible colours? See the UX/UI design course⁠ at Nexfield Academy.

License: MIT

Tag summary

Content type

Image

Digest

sha256:d2baa7d08…

Size

51.7 MB

Last updated

5 days ago

docker pull nexfield/contrast