Brand on surface
Readable color starts with a measured pair.
#806eae4.22:1AA normal failTurn a foreground and background into one ratio, then test the threshold required by the text that uses them.
Brand on surface
Readable color starts with a measured pair.
#806eae4.22:1AA normal failText on surface
Readable color starts with a measured pair.
#1e293b13.98:1AAA normal passThe brand pair reaches 4.217159621711113:1: enough for AA large text, not AA normal text. The text pair reaches 13.981703505432394:1.
calculate() returns the ratio. meetsFor() combines the pair with an explicit WCAG level and text-size branch.
<?php
use PhpColor\Color\Color;
use PhpColor\Color\Contrast\ColorContrast;
use PhpColor\Color\Contrast\WcagLevel;
$foreground = Color::parse('#806eae');
$background = Color::parse('#f8fafc');
$ratio = ColorContrast::calculate($foreground, $background);
$passes = ColorContrast::meetsFor(
$foreground,
$background,
WcagLevel::AA,
);
// 4.217159621711113
// false
use PhpColor\Color\Color;
use PhpColor\Color\Contrast\ColorContrast;
use PhpColor\Color\Contrast\WcagLevel;
$foreground = Color::parse('#806eae');
$background = Color::parse('#f8fafc');
$ratio = ColorContrast::calculate($foreground, $background);
$passes = ColorContrast::meetsFor(
$foreground,
$background,
WcagLevel::AA,
);
// 4.217159621711113
// false
The calculation assumes the supplied colors and WCAG 2.x thresholds. It does not inspect font size, weight, antialiasing, gradients, images, interaction states, or DOM rendering.