When we rebuilt webiato.co, I wanted it in two versions: the dark black-and-green brand look, and a light one, with a switch in the header so visitors can choose.
Impreza can do this without plugins or custom JavaScript. It still took us a few tries to get right, so here’s how it works, the steps, and the three snags that tripped us up.
How Impreza’s switch works
There are two pieces. The first is your site’s normal colour palette in Theme Options → Colors, which is what visitors see by default. The second is a saved Color Scheme, which holds the colours for the other mode.
The Header Builder has a colour scheme switch element. When a visitor turns it on, Impreza applies the saved scheme on top of your default colours and adds the class us-color-scheme-on to the page’s <html> tag. That class matters later, because it’s how you swap logos and images between modes.
Setting it up
- Define your brand colours once. Add them as Custom Global Colors in Theme Options → Colors, then point every colour picker at those tokens instead of typing hex values. You’ll thank yourself later.
- Load the full light palette. Set every header, content and footer colour to its light-mode value.
- Save it as a scheme. At the top of Theme Options → Colors, open the Color Schemes panel and save the current colours as a new custom scheme. We called ours “Webiato Light.”
- Put your default back. Restore the dark palette as the site’s live colours, since that’s what visitors see first.
- Add the switch to your header. In the Header Builder, add the colour scheme switch element and point it at the scheme you saved. We used a moon and a sun as its labels, and brand colours for its on and off states.
- Make sure that header is actually in use. Check that it’s set as the default header in Theme Options, or the switch won’t appear anywhere.
- Test in a private window. Toggle it, reload, and confirm the choice sticks.
Where it went wrong for us
The scheme saved old colours. Our first save came from a Theme Options tab that had been open for a while, so it captured outdated values. Reload Theme Options right before you save a scheme.
Hand-editing only half-converted it. I later tweaked the colour pickers by hand and saved over the scheme. The backgrounds switched to light, but the text colours didn’t, so light mode had pale text on a pale background. The fix was to load the complete palette first, then save the scheme without touching individual pickers.
The switch didn’t show up at all. The site had no default header assigned, so the header holding the switch wasn’t used on any page. Setting it as the default header fixed it instantly.
Swapping logos and images between modes
Colours switch on their own, but images don’t. A light logo disappears on a light background, so you need two versions and a way to show the right one.
Place both images, and give each Image element an extra class: logo-light on the version for dark mode, and logo-dark on the version for light mode. Then add this to Theme Options → Custom Code → CSS:
.w-image.logo-dark,
html.us-color-scheme-on .w-image.logo-light {
display: none;
}
html.us-color-scheme-on .w-image.logo-dark {
display: block;
}
The same two classes work for any image that needs a light and dark version, not just the logo. We reuse them for the illustrations on our Services page.
Keeping both modes in sync
Because our pickers point at Custom Global Colors, the saved scheme records which brand colour goes where, not fixed hex values. If we change the green later, both modes update automatically.
The one thing that needs a re-save is changing which colour a setting uses in light mode. Load the full light palette again, save the scheme, then put the default back, the same way you set it up. Settings that aren’t colours, like fonts and button sizes, are shared between modes and never need re-saving.
It’s also worth deciding up front what shouldn’t switch. On our site, the footer and the deep-green call-to-action band stay dark in both modes, and our “alternate” rows flip so contrast sections still stand out.
Want us to look at your site?
Tell us where you are and where you want to be. We reply within one business day.
Written by
John Go
President and CEO of Webiato. Building and caring for websites for over a decade.