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
| Name | Type | Default |
|---|---|---|
$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
| Name | Type | Default |
|---|---|---|
$name |
string | - |
light
static
public static function light(array $vars, ColorInterface|string|null $currentColor): CssContext
Create a light-mode context.
Parameters
| Name | Type | Default |
|---|---|---|
$vars |
array | [] |
$currentColor |
ColorInterface|string|null | null |
public function withCurrentColor(ColorInterface|string $color): CssContext
Return a new context with a different current color.
Parameters
| Name | Type | Default |
|---|---|---|
$color |
ColorInterface|string | - |
public function withVar(string $name, string $value): CssContext
Return a new context with an additional CSS variable.
Parameters
| Name | Type | Default |
|---|---|---|
$name |
string | - |
$value |
string | - |