Skip to content

[css-fonts-5] Allow to define palette colors outside of @font-palette-values #9046

@SebastianZ

Description

@SebastianZ

Thinking about the proposal for animating font-palette in #8922, the question I had in mind was, why not allow to animate the different colors individually?

The main benefit of that is that you can transition each color individually and with that also define the interpolation color space. And besides the transition/animation use case, you'd be able to change each color on usage. That would require a new property to access and overwrite the colors outside of @font-palette-values, e.g. called font-palette-color.

Syntax suggestion:

font-palette-color: [ <integer [0,∞]> [ <absolute-color-base> | from-palette ] ]#

So it would basically work like the override-colors descriptor descriptor but may also use the color from the palette via the from-palette keyword.

Example for an animation:

@keyframes --palette-animation {
  from {
    font-palette-color:
      1 red,
      2 from-palette
      3 oklch(0.63 0.12 105.7);
  }
  to {
    font-palette-color:
      1 blue,
      2 hsl(80 90% 60%),
      3 oklch(0.5 0.90 185.7);
  }
}

One open question is what to do with colors not defined in font-palette-color and font-palette itself is not animated. Possible solutions I can think of:

  1. Use the colors from the palettes and
    1. interpolate them like other colors
    2. interpolate them discretely
  2. Use a default color like currentcolor (that might also be overwritten by allowing to define a color without index, e.g. font-palette-color: black, 2 blue; would set the second color to blue and the rest of the colors in the palette to black)

Initially, I wanted to add that as a comment to #8922, though as it covers additional use cases besides animation and is orthogonal to the proposal there, I thought it would be worth to discuss this separately.

Sebastian

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.css-fonts-5

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions