Blog / Design

Dark mode charts: colours, contrast and theming that actually work

A chart that looks right in light mode often fails in dark: colours glare, gridlines vanish, tooltips disappear. The fix is a tuned second palette, switched with CSS variables, not an inversion.

By Abdullah NomanNovember 30, 20263 min read

Laptop dashboard, hairline isometric illustration

Short answer: give charts their own dark palette instead of inverting the light one. Lower the brightness of series colours slightly, keep enough contrast with the background, make gridlines a step lighter than the surface (not white), and switch everything with CSS variables so one component serves both themes.

Why not just invert the colours?

Inversion turns your brand indigo into a muddy yellow and your soft backgrounds into harsh blacks. Saturated colours that look calm on white also appear to glow on near-black, so a straight copy of the light palette feels loud. Each theme needs its own tuned values.

What changes between light and dark?

ElementLightDark
BackgroundWhite or near-whiteDark grey, not pure black
Series coloursMid-saturationSlightly lighter, slightly less saturated
GridlinesLight grey, dotted or thinA grey just above the surface
LabelsMid greyLight grey, not white
TooltipDark on lightLight on dark, or a raised surface

How do you theme React charts with CSS variables?

Reference variables in the SVG (stroke="var(--c1)"), define them once on the chart container, and redefine them under your dark selector:

.ch { --c1: #5b5fe9; --grid: #eceef2; --muted: #9a9dab; }
.dark .ch { --c1: #6b6ff0; --grid: #23252b; --muted: #7d8090; }

No re-render and no theme prop: when the dark class lands on the page, every chart switches at once. This is how Liniqo Charts works; it follows a .dark class (Tailwind, next-themes) or data-theme="dark".

How do you keep colours accessible in both themes?

  • Check the palette for colour-blind separation in each theme, not just light.
  • Do not rely on colour alone: add direct labels, patterns or a legend in series order.
  • Keep text labels at a readable contrast against the surface they sit on.

What about illustrations next to charts?

Dashboards mix charts with empty states and onboarding art, and those need dark versions too. See dark mode illustrations for the same approach applied to artwork.

Questions

Should charts use pure black backgrounds in dark mode?

Usually not. A dark grey surface is easier on the eyes and lets gridlines and shadows still read.

Can I reuse my light chart colours in dark mode?

Start from them, but tune each one: slightly lighter and less saturated so they do not glow on a dark surface.

How do I switch chart themes in React?

Reference CSS variables in the SVG and redefine them under a dark selector such as a .dark class; no re-render is needed.

Do Liniqo Charts support dark mode?

Yes. Every chart has a tuned dark palette that switches with a .dark class or data-theme="dark" on any parent element.

Keep reading