Export palette variables
Turn named application colors into CSS custom-property declarations without rebuilding the mapping by hand.
Palette
brand
#806eae
accent
#d97706
surface
#f8fafc
--theme-brand: #806eae;
--theme-accent: #d97706;
--theme-surface: #f8fafc;
The palette keys become stable CSS names
PHPColor keeps the supplied order and prefixes each name. The exported artifact contains declarations that can be placed inside the selector chosen by the application.
Export the complete named collection once
toCssVariables() accepts the variable prefix and serializes every palette member as hexadecimal CSS.
<?php
use PhpColor\Color\Palette\ColorPalette;
$palette = ColorPalette::parse([
'brand' => '#806eae',
'accent' => '#d97706',
'surface' => '#f8fafc',
]);
echo $palette->toCssVariables('theme');
// --theme-brand: #806eae;
// --theme-accent: #d97706;
// --theme-surface: #f8fafc;
use PhpColor\Color\Palette\ColorPalette;
$palette = ColorPalette::parse([
'brand' => '#806eae',
'accent' => '#d97706',
'surface' => '#f8fafc',
]);
echo $palette->toCssVariables('theme');
// --theme-brand: #806eae;
// --theme-accent: #d97706;
// --theme-surface: #f8fafc;
Supply names and stylesheet structure yourself
Only named palettes can become variables. PHPColor preserves those names but exports hexadecimal values without alpha; it does not infer semantic roles, emit a selector, or produce a design-token document.
IncludedOrdered hexadecimal declarations.
RequiredA named palette and explicit prefix.
Not includedAlpha, selector, cascade, or media query.
Not inferredSemantic roles or token metadata.