CssContext

Resolution environment for CSS color expressions.

Stores runtime values such as CSS variables, color scheme preference, and
the current foreground color, which are needed to resolve late-bound CSS colors.

Methods

public function colorScheme(): string

Get the active color scheme ('light', 'dark', or null).

dark

static
public static function dark(array $vars, ColorInterface|string|null $currentColor): CssContext

Create a dark-mode context.

Parameters
NameTypeDefault
$vars array []
$currentColor ColorInterface|string|null null
public function getCurrentColor(): ColorInterface|string|null

Get the current foreground color.

public function getVar(string $name): string

Get the value of a CSS variable by name.

Parameters
NameTypeDefault
$name string -
public function isStrict(): bool

Check if strict resolution is enabled.

light

static
public static function light(array $vars, ColorInterface|string|null $currentColor): CssContext

Create a light-mode context.

Parameters
NameTypeDefault
$vars array []
$currentColor ColorInterface|string|null null
public function withCurrentColor(ColorInterface|string $color): CssContext

Return a new context with a different current color.

Parameters
NameTypeDefault
$color ColorInterface|string -
public function withVar(string $name, string $value): CssContext

Return a new context with an additional CSS variable.

Parameters
NameTypeDefault
$name string -
$value string -