Short answer: override --ifm-color-primary and its six shades in src/css/custom.css

How to change Docusaurus theme colors

In Docusaurus 3.10.2, the current stable version, you change the theme colors by overriding Infima's CSS variables, --ifm-color-primary and its six shades, in src/css/custom.css. Docusaurus styles its classic preset with Infima, so editing these variables changes the palette across your whole documentation site. To see a palette on your real docs before you edit that file, load the deployed site in Recolor (recolor.page) and press Space in the Recolor app.

Last updated

What Docusaurus's Styling and Layout docs for version 3.10.2 say about its colors, read 14 Nov 2026, beside Recolor
StepIn DocusaurusIn Recolor
Try a paletteThe docs' generator, previewed on the Docusaurus website itselfPress Space on your own deployed docs
Make the shadesThe generator makes six shades from one primary colorNot offered: each swatch is one color
Check contrastThe generator rates each shade against the background: AAA, AA or FailEach swatch's contrast with black and white text
Dark modeA second block under [data-theme='dark']Not listed
Set the colors--ifm-color-primary and six shades in src/css/custom.cssHex list or CSS variables from Export, renamed by hand

Where Docusaurus keeps its colors

With @docusaurus/preset-classic, Docusaurus styles every page with Infima, its styling framework, and Docusaurus's Styling and Layout docs say you can override Infima's CSS variables globally. You do it in your own stylesheet.

Create src/css/custom.css and pass it to the classic theme as customCss in docusaurus.config.js, as the docs show:

JavaScript
export default {
  // ...
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        theme: {
          customCss: ['./src/css/custom.css'],
        },
      },
    ],
  ],
};

Any CSS in that file applies to the whole site. When you place CSS variable overrides in this stylesheet, Infima applies those values to components and layouts across all pages.

The primary color and its six shades

Docusaurus's Styling and Layout docs say Infima uses 7 shades of each color: --ifm-color-primary, then -dark, -darker, -darkest, -light, -lighter and -lightest. Each is its own variable, so changing only the first leaves the other six as they were.

The Styling and Layout page has a color generator. You type one primary color and it makes the six shades, rates each against the background as AAA, AA or Fail, and previews them on the Docusaurus website itself. Its tip says to aim for at least WCAG AA contrast for the primary. Recolor does not make shades. A swatch in Recolor is one color.

For #264653, the generator gives this block, with lowercase hex as it writes it:

CSS
:root {
  --ifm-color-primary: #264653;
  --ifm-color-primary-dark: #223f4b;
  --ifm-color-primary-darker: #203c47;
  --ifm-color-primary-darkest: #1b313a;
  --ifm-color-primary-light: #2a4d5b;
  --ifm-color-primary-lighter: #2c515f;
  --ifm-color-primary-lightest: #315b6c;
}

Dark mode

In dark mode the html element carries data-theme="dark", so the docs scope dark colors with [data-theme='dark']. One color does not usually work in both modes, the tip says.

The hex code #264653 reads 10.08:1 with white text, too dark for a dark background. In contrast, #2a9d8f reads 3.32:1 with white and 6.32:1 with black, so it suits dark mode. Its generator block provides these shades:

CSS
[data-theme='dark'] {
  --ifm-color-primary: #2a9d8f;
  --ifm-color-primary-dark: #268d81;
  --ifm-color-primary-darker: #24857a;
  --ifm-color-primary-darkest: #1d6e64;
  --ifm-color-primary-light: #2ead9d;
  --ifm-color-primary-lighter: #30b5a4;
  --ifm-color-primary-lightest: #39cab8;
}

Try the palette on your live docs first

Load your deployed docs by their address in Recolor, press Space until a palette fits, and lock the colors you keep. Each swatch shows its contrast with black or white text, marked for 4.5:1. A localhost address is refused, since Recolor loads public addresses. You can upload a saved page instead. Photos keep their own colors.

Export's names do not paste in as they are. Its CSS variables are --color-1 to --color-5 with --color-primary, --color-secondary and --color-accent, which Infima never reads. The details of these variable names appear on the page for exports. Copy a swatch's hex from the Hex tab into the generator, then paste the generator's block into your stylesheet.

How variables carry a palette across a project is explained in the guide to recoloring with CSS variables. To inspect all pairings of light and dark values across your selections, the contrast matrix grades every pair.

Common questions

Is --ifm-color-primary the only color I need to change?

No. Infima uses seven shades of the primary, each its own variable. Changing only --ifm-color-primary leaves the other six shades as they were.

Does Docusaurus make the shades for me?

Yes. The generator on its Styling and Layout page makes six shades from one color. Recolor does not make shades.

Can I paste Recolor's CSS export into custom.css as it is?

No. Infima reads --ifm-color-primary, not --color-1 or --color-primary, so take the hex codes and rename by hand. You can also paste the hex value into Docusaurus's generator to obtain the full set of shade variables.

Do I need a separate color for dark mode?

Yes, usually. The docs put dark colors under [data-theme='dark'], since one color rarely works in both modes. A color with suitable contrast against white is often too dark on a deep background.

Is it free?

Yes. Loading a site, generating palettes and every export format are free, without an account.

Sources