Custom CSS has no effect once a visitor toggles dark mode

What you are seeing

You have added custom CSS to your site, but it has no effect once a visitor toggles dark mode.


#Why it happens

The site’s built-in colour palette uses more specific selectors than a plain :root rule. If your CSS sets its overrides on a bare :root, the built-in palette wins and your changes never show.


#What to do

Write the light block as :root, :root.light and the dark block as :root.dark, instead of a bare :root. Add a rule for each mode you want to change, so your styles hold whichever mode a visitor picks.

/* Light mode */
:root,
:root.light {
  /* your overrides */
}

/* Dark mode */
:root.dark {
  /* your overrides */
}

Custom CSS is in the site's Settings, under Custom CSS. In an empty editor, Start from an example gives you this pattern.



Found it? Good.