The read-only basePalette property of the CSSFontPaletteValuesRule interface indicates the base palette associated with the rule.
The read-only basePalette property of the CSSFontPaletteValuesRule interface indicates the base palette associated with the rule.
A string that can be one of the following color values:
lightMatches the first palette in the font file that is marked as applicable to a light background, that is, close to white. If there is no palette in the font or if no palette has the required metadata, the value is equivalent to "0", that is, the first palette in the font.
darkMatches the first palette in the font file that is marked as applicable to a dark background, that is, close to black. If there is no palette in the font or if no palette has the required metadata, the value is equivalent to "0", that is, the first palette in the font.
"0", "1", …)Matches the palette corresponding to the index. The first palette corresponds to "0".
This example adds rules in an extra stylesheet added to the document, returned as the last stylesheet in the document (document.styleSheets[document.styleSheets.length-1].cssRules). So, rules[2] returns the first CSSFontPaletteValuesRule object, and rules[3] the second one.
html
<h2>default base-palette</h2> <h2 class="two">base-palette at index 2</h2> <h2 class="five">base-palette at index 5</h2> <pre id="log"></pre>
css
@import url("https://fonts.googleapis.com/css2?family=Nabla&display=swap"); h2 { font-family: "Nabla"; } @font-palette-values --two { font-family: "Nabla"; base-palette: 2; } @font-palette-values --five { font-family: "Nabla"; base-palette: 5; } .two { font-palette: --two; } .five { font-palette: --five; }
js
const log = document.getElementById("log"); const rules = document.styleSheets[document.styleSheets.length - 1].cssRules; const twoRule = rules[2]; // A CSSFontPaletteValuesRule interface const fiveRule = rules[3]; // A CSSFontPaletteValuesRule interface log.textContent = `The ${twoRule.name} @font-palette-values base palette is: ${twoRule.basePalette}\n`; log.textContent += `The ${fiveRule.name} @font-palette-values base palette is: ${fiveRule.basePalette}`;
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
basePalette | 
101 | 101 | 107 | No | 87 | 15.4 | 101 | 101 | 107 | 70 | 15.4 | 19.0 | 
@font-palette-values at-rulebase-palette descriptor
    © 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
    https://developer.mozilla.org/en-US/docs/Web/API/CSSFontPaletteValuesRule/basePalette