Skip to main content

require-ifm-color-primary-scale-per-color-mode

Require matching Infima primary color-scale overrides for each Docusaurus color mode you customize.

Targeted pattern scopeโ€‹

This rule checks primary-scale overrides in Docusaurus theme scopes such as:

  • :root
  • [data-theme='light']
  • [data-theme='dark']

It focuses on whether you customize the primary scale in both light/default and dark mode, not on whether each individual scope contains every required variable. The existing require-ifm-color-primary-scale rule covers the full-scale requirement within a touched scope.

What this rule reportsโ€‹

This rule reports files that customize Infima primary-scale variables in only one color mode.

Why this rule existsโ€‹

Docusaurus explicitly encourages different palettes in light and dark mode because one primary color scale rarely works equally well in both.

If you customize only one mode, the other mode may fall back to an unrelated default palette and the site can feel inconsistent during color-mode switches.

โŒ Incorrectโ€‹

:root {
--ifm-color-primary: #4f46e5;
}

โœ… Correctโ€‹

:root {
--ifm-color-primary: #4f46e5;
}

[data-theme="dark"] {
--ifm-color-primary: #818cf8;
}

Behavior and migration notesโ€‹

  • This rule is intentionally stricter than Docusaurus itself.
  • It complements require-ifm-color-primary-scale instead of replacing it.
  • It is report-only because choosing a second color palette is a design decision.

Additional examplesโ€‹

โŒ Incorrect โ€” dark mode customized without a matching light/default scopeโ€‹

[data-theme="dark"] {
--ifm-color-primary: #818cf8;
}

โœ… Correct โ€” explicit light-mode scope instead of :rootโ€‹

[data-theme="light"] {
--ifm-color-primary: #4f46e5;
}

[data-theme="dark"] {
--ifm-color-primary: #818cf8;
}

Stylelint config exampleโ€‹

import { docusaurusPluginConfigs } from "stylelint-plugin-docusaurus";

export default {
...docusaurusPluginConfigs["docusaurus-all"],
rules: {
...docusaurusPluginConfigs["docusaurus-all"].rules,
"docusaurus/require-ifm-color-primary-scale-per-color-mode": true,
},
};

When not to use itโ€‹

Disable this rule if your design intentionally uses the same Infima primary palette for both light and dark mode, or if you are comfortable leaving one mode on the framework defaults.

Package documentationโ€‹

Docusaurus package documentation:

Rule catalog ID: R014

Further readingโ€‹