@font-palette-values

Term side of the Card.
Topic: Directives
Unit title: @font-palette-values
Categories: Directive
Explanation side of the Card

Explanation: The directive that defines a custom color palette for a color font, overriding chosen colors of its built-in palettes. The palette is applied with the `font-palette` property, letting multi-color icon or emoji fonts match a site's colors.

Browser compatibility:
  • The chrome browser supports this feature starting from version 101.
  • The edge browser supports this feature starting from version 101.
  • The firefox browser supports this feature starting from version 107.
  • The safari browser supports this feature starting from version 15.4.
Availability: 

Example

Wrongcss
.title {
  font-family: "Bungee Spice";
  color: crimson;
}
Rightcss
@font-palette-values --warm {
  font-family: "Bungee Spice";
  override-colors: 0 crimson, 1 gold;
}
.title {
  font-family: "Bungee Spice";
  font-palette: --warm;
}

color does not recolor a color font; a custom palette overrides its built-in colors by index.

Common mistakes

  • Applying a palette to a regular font, which has no color layers.
  • Using a palette name without --, which is invalid.

Key points

  • The rule names font-family exactly as declared in @font-face.
  • The palette name starts with -- and is applied through font-palette.

Interview questions

What does base-palette do?

It picks one of the palettes built into the font as the starting point, by index, before override-colors applies.

Can I switch font palettes for dark mode?

Yes, set a different font-palette inside a prefers-color-scheme: dark media query.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy