Resolve currentColor

Supply one foreground color explicitly and resolve the CSS keyword to a concrete PHPColor value.

Expression currentColor
Current foreground var(--brand) --brand: #806eae
Resolved #806eae SrgbColor

Resolve the foreground supplied by your application

The context stores currentColor as var(--brand). PHPColor follows that additional lookup and returns the concrete sRGB color.

Supply the current foreground

The value may be a concrete color or a resolvable string. The context remains immutable after construction.

<?php

use PhpColor\Color\Css\CssColor;
use PhpColor\Color\Css\CssContext;

$variables = ['--brand' => '#806eae'];
$context = CssContext::light($variables, 'var(--brand)');

$expression = CssColor::currentColor();
$color = CssColor::resolve($expression, $context);

echo $color->toHex(); // #806eae
use PhpColor\Color\Css\CssColor; use PhpColor\Color\Css\CssContext; $variables = ['--brand' => '#806eae']; $context = CssContext::light($variables, 'var(--brand)'); $expression = CssColor::currentColor(); $color = CssColor::resolve($expression, $context); echo $color->toHex(); // #806eae

Context is not DOM inheritance

PHPColor resolves only the foreground value stored in CssContext. It does not discover that value in a rendered document.

No browser lookup

PHPColor does not find an element, traverse ancestors, match selectors, calculate the cascade, or inspect computed styles.

Missing context stays visible

Without a current foreground, non-strict resolution retains currentColor. Strict resolution throws. A supplied but unresolved string remains deferred.

Resolve another context

Supply the foreground and inspect the concrete color