CKTIS / CSS
@font-palette-values — a custom color-font palette
The @font-palette-values rule names a base palette from a color font and optionally replaces selected palette colors.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
@font-palette-values <dashed-ident> {
<declaration-list>
}@font-palette-values <dashed-ident> { ... } defines a palette for the family named by its font-family descriptor. The rule name must begin with --. base-palette selects a palette from the font by numeric index or the light or dark preference, while override-colors contains color-index and replacement-color pairs.
Select the definition with font-palette: --brand. It affects only a color font that actually contains suitable palette data; it neither changes an ordinary monochrome font nor loads the family. A color index addresses an entry in the selected palette, and an out-of-range index does not create a new entry.
A valid computed value can therefore have no visible effect when a fallback face is selected, the font has no palettes, or an index is absent. A new font version that reorders palettes can also change the meaning of a numeric base index. The example registers --brand, overrides color 0, and reads the real CSSOM rule and computed font-palette value.
Examples
const style = document.createElement('style');
style.textContent = `@font-palette-values --brand { font-family: Demo; base-palette: 0; override-colors: 0 rgb(255, 0, 0); }
.probe { font-family: Demo, sans-serif; font-palette: --brand; }`;
document.head.append(style);
const probe = document.createElement('div');
probe.className = 'probe';
probe.textContent = 'CKTIS';
document.body.append(probe);
const rule = style.sheet.cssRules[0];
console.log('rule=' + rule.constructor.name + '; css=' + rule.cssText.replace(/\s+/g, ' ') + '; used=' + getComputedStyle(probe).fontPalette);Result
rule=CSSFontPaletteValuesRule; css=@font-palette-values --brand { font-family: Demo; base-palette: 0; override-colors: 0 rgb(255, 0, 0); }; used=--brandThe @font-palette-values rule names a base palette from a color font and optionally replaces selected palette colors.