On this page

Guides

Palettes

A palette is a named set of values for some of the color tokens. The default palette is tuned so that marks keep their contrast on the light and the dark surface. There is one other, vivid, which restores the brighter light colors that the library used before 0.6b for three tokens: --ch-warn, --ch-gain and --ch-neutral.

Choosing a palette #

Set data-ch-palette="vivid" on <html>, on any ancestor of a chart, or on the element that also has data-ch-theme.

app/layout.tsx
<html lang="en" data-ch-palette="vivid">
  <body>{children}</body>
</html>

Your own --ch-* overrides on a descendant still win over the palette. Everything that is not one of the three tokens is unchanged.

Swatches #

The default palette, with the contrast of each color against --ch-surface of the same theme:

  • --ch-accent
    Light
    #24356b11.20:1
    Dark
    #7f9be66.89:1
  • --ch-accent-soft
    Light
    #a9b6de1.93:1
    Dark
    #6f80b44.83:1
  • --ch-loss
    Light
    #e8505b3.51:1
    Dark
    #ff6b746.77:1
  • --ch-warn
    Light
    #be802f3.18:1
    Dark
    #ffb24d10.44:1
  • --ch-gain
    Light
    #3a93b83.33:1
    Dark
    #5cc0e69.03:1
  • --ch-neutral
    Light
    #8e8e953.12:1
    Dark
    #7c7c864.53:1

Contrast is against --ch-surface of the same theme.

The vivid palette changes --ch-warn, --ch-gain and --ch-neutral in the light theme only:

  • --ch-accent
    Light
    #24356b11.20:1
  • --ch-accent-soft
    Light
    #a9b6de1.93:1
  • --ch-loss
    Light
    #e8505b3.51:1
  • --ch-warn
    Light
    #f1a23b2.02:1
  • --ch-gain
    Light
    #4fa3c72.72:1
  • --ch-neutral
    Light
    #a3a3ab2.40:1

Light only: the palette does not change the dark theme. Contrast is against --ch-surface of the same theme.

Side by side #

Both panels below are pinned to the light theme, because the palette does not apply to the dark one, and both have a --ch-surface background. The panel on the right also has data-ch-palette="vivid", on the same element as data-ch-theme. The chart uses the gain, neutral and warn tones.

Margin by week, default palette
View of Margin by week, default palette

Limits #

  • Light only. Where the effective theme is dark (data-ch-theme="dark" or a dark system preference) the tokens are the normal dark ones, so a visitor in dark mode sees no difference.
  • Forced colors win. In Windows high contrast mode the tokens stay system colors, whatever the palette.
  • Nesting. A data-ch-theme="dark" element nested inside a light one, with a bare palette element below it, gets vivid colors in a dark region. Put the attribute on <html> or on the themed element itself to avoid it.
  • Contrast. The three vivid colors are below 3:1 against the light surface (warn 2.0:1, gain 2.9:1, neutral 2.4:1), so marks in these tones are harder to see than by default. Do not rely on the color alone to tell marks apart.

See Theming for the tokens and Dark mode for the theme attribute.