Generate a complementary palette

Pair a source color with the color opposite it on the perceptual hue wheel.

Use complementary() for a two-color harmony separated by 180 degrees in OKLCH:

use PhpColor\Color\Color;
use PhpColor\Color\Palette\ColorPalette;

$brand = Color::parse('#7c3aed');
$palette = ColorPalette::scale([
    $brand,
    $brand->complementary(),
]);

assert(['#7c3aed', '#757700'] === $palette->toHex());
use PhpColor\Color\Color; use PhpColor\Color\Palette\ColorPalette; $brand = Color::parse('#7c3aed'); $palette = ColorPalette::scale([ $brand, $brand->complementary(), ]); assert(['#7c3aed', '#757700'] === $palette->toHex());

The returned complement keeps the source color space. The geometric relationship does not guarantee equal contrast, equal visual weight, or an in-gamut CSS result for every source color.

Explore color harmonies or read the harmony guide.