大网数据广告活动
Web 标准与前端开发

`@font-palette-values` CSS at-rule

· 52CE 我爱测

The **`@font-palette-values`** CSS at-rule allows you to customize the default values of font-palette created by the font-maker.

The @font-palette-values CSS at-rule allows you to customize the default values of font-palette created by the font-maker.

Syntax

@font-palette-values --identifier {
  font-family: "Bixa";
}
.my-class {
  font-palette: --identifier;
}

The <dashed-ident> is a user-defined identifier, that while it looks like a CSS custom property behaves in a different way and is not wrapped in a CSS var() function.

Descriptors

  • @font-palette-values/base-palette
    • : Specifies the name or index of the base-palette, created by the font-maker, to use.
  • @font-palette-values/font-family
    • : Specifies the name of the font family that this palette can be applied to. A font-family name is required for the @font-palette-values rule to be valid.
  • @font-palette-values/override-colors
    • : Specifies the colors in the base palette to override.

Formal syntax

Examples

Overriding colors in an existing palette

This example shows how you can change some or all of the colors in a color font.

HTML

<p>default colors</p>
<p class="alternate">alternate colors</p>

CSS

@import "https://fonts.googleapis.com/css2?family=Bungee+Spice";
p {
  font-family: "Bungee Spice", fantasy;
  font-size: 2rem;
}
@font-palette-values --Alternate {
  font-family: "Bungee Spice";
  override-colors:
    0 #00ffbb,
    1 #007744;
}
.alternate {
  font-palette: --Alternate;
}

Result

When overriding colors of the normal or base-palette at index 0 you do not need to declare which base-palette to use. This should only be done when overriding a different base-palette. If you are overriding all the colors then there is also no need to specify the base-palette to use.

Overriding colors in an existing palette

Specifications

Browser compatibility

See also

  • font-palette property
  • @font-palette-values/font-family descriptor
  • @font-palette-values/base-palette descriptor
  • @font-palette-values/override-colors descriptor
  • CSSFontPaletteValuesRule

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。