Squarespace does not have a built-in dark mode toggle for visitors, but you can add one for free. Paste the code below into Code Injection, and a small moon button appears in the corner of every page. One tap switches your whole site to dark mode, photos keep their real colors, and the site remembers each visitor’s choice. It can also follow the visitor’s device setting automatically.
I’m Sukesh Das, a Squarespace Circle Platinum Partner. I have built more than 1,200 websites since 2018. A light and dark mode switch is one of the most requested features in the Squarespace community, and it is one of the top wishes on widget wishlists too, yet most solutions are paid plugins. So I wrote a free Squarespace dark mode toggle that works with any Squarespace 7.1 design.
Squarespace dark mode toggle options at a glance
| Option | Visitor can switch? | Effort | Best for |
|---|---|---|---|
| Design your site in dark colors (Site Styles) | No | Low | A site that is always dark |
| Free Squarespace dark mode toggle (this guide) | Yes | One paste | Any site that wants a light and dark switch |
| Paid theme switcher plugin | Yes | Plugin setup | Teams who want a settings screen |
| Custom designed dark theme | Yes | Custom build | Brands that want exact dark colors |
Does Squarespace have a dark mode?
Not for visitors. Squarespace lets you pick dark color themes for your sections in Site Styles, so you can design a site that is dark all the time. What it does not offer is a switch that lets each visitor choose light or dark, the way many apps and big websites do.
That is the gap a Squarespace dark mode toggle fills. Visitors who browse at night, or who simply prefer dark screens, get a darker version of your site with one tap, while everyone else sees your normal design.
A toggle also lets you keep the light design you have already invested in. You do not need to redesign anything or maintain two versions of your site. The dark version is generated from your existing design every time a visitor switches.
How does this Squarespace dark mode toggle work?
Instead of trying to rewrite every color on your site, the code uses a smart color flip. When dark mode is on, the page colors are inverted, so white backgrounds become near black and dark text becomes light. At the same time, photos, videos, maps and background images are flipped back, so they keep their real colors.
Sections that are already dark are left alone. Before switching, the code checks every section: if it has a dark background, light text, or a photo or video background, it stays exactly as you designed it. Only your light sections turn dark, so text is always readable, whether your site mixes light and dark sections or not.
The big advantage is that it works with any Squarespace design, any color theme and any section layout, without you having to pick a dark version of every color. The trade-off is that you do not choose the exact dark colors yourself. Your brand colors shift to their natural dark equivalents, and very bright yellows can look a little softer.
For most service, coaching and portfolio sites, the result looks clean and natural. If your brand depends on exact colors in dark mode, a custom dark theme is the better route, which I cover at the end.
Before you start
- Code Injection needs a Core, Plus or Advanced plan, or one of the older Business and Commerce plans. Find it at
Website → Pages → Custom Code → Code Injection. - Use the Header box, not the Footer. The code needs to run before the page appears, so returning dark mode visitors never see a white flash.
- Check your logo. If your logo is a dark image on a light background, you will want it to flip to light in dark mode. The settings handle this.
How do I add a Squarespace dark mode toggle to Squarespace?
- Open
Website → Pages → Custom Code → Code Injection. - Paste the full code below into the Header box.
- Click Save.
- Open your site in a private window and tap the moon button in the bottom corner.
<!-- Light and Dark Mode Toggle by Sukesh Das, sukeshdas.com -->
<!-- Paste this whole block into your site's HEADER code area (Squarespace: Code Injection > Header) so the page never flashes white -->
<script>
/* ============ SETTINGS: edit these values ============ */
window.SukeshDasDarkModeSettings = {
followSystem: false, // false = always open with your site's own design; true = open dark if the visitor's device is set to dark
remember: true, // true = remember the visitor's choice on their next visit
position: "left", // "left" or "right" (bottom corner of the screen)
bottom: 20, // Distance from the bottom of the screen (px)
side: 20, // Distance from the side of the screen (px)
size: 48, // Button size (px)
lightButton: "#0A0B0F", // Button color in light mode
darkButton: "#F2F4F7", // Button color in dark mode
keepDarkSections: true, // true = sections that are already dark (or use a photo/video background) stay exactly as designed
keepColors: "img, video, iframe, picture, [style*='background-image']", // Things that keep their real colors
logo: ".header-title-logo img, .header-mobile-logo img", // Your logo: a black or dark gray logo turns white in dark mode, a colored logo keeps its colors
alsoInvert: ".sd-invert, iframe[src*='acuityscheduling.com']", // Things that SHOULD turn dark too, like black icons or the booking calendar
hideOn: [] // Pages where the toggle is hidden, e.g. ["/checkout"]
};
/* ============ END OF SETTINGS ============ */
</script>
<script>
/* Light and Dark Mode Toggle by Sukesh Das, sukeshdas.com. Please keep this credit. */
(function () {
var KEY = "sukeshdas-theme";
var root = document.documentElement;
class SukeshDasDarkMode {
constructor(s) {
this.s = s || {};
this.sukeshAddStyles();
this.sukeshApply(this.sukeshStartTheme(), false);
var self = this;
var start = function () { self.sukeshBuildButton(); };
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start);
else start();
}
sukeshStartTheme() {
var saved = null;
try { saved = this.s.remember ? localStorage.getItem(KEY) : null; } catch (e) {}
if (saved === "dark" || saved === "light") return saved;
var prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
return this.s.followSystem && prefersDark ? "dark" : "light";
}
sukeshApply(theme, save) {
if (theme === "dark" && this.btn) this.sukeshFindDarkSections(); // re-check sections that loaded late
root.classList.toggle("sd-dark", theme === "dark");
if (save && this.s.remember) { try { localStorage.setItem(KEY, theme); } catch (e) {} }
if (this.btn) {
this.btn.setAttribute("aria-pressed", theme === "dark" ? "true" : "false");
this.btn.setAttribute("aria-label", theme === "dark" ? "Switch to light mode" : "Switch to dark mode");
}
}
sukeshAddStyles() {
var s = this.s, side = s.position === "right" ? "right" : "left";
var flip = "filter:invert(1) hue-rotate(180deg)";
var unflip = "filter:hue-rotate(180deg) invert(1)"; // exact reverse of flip, so photos keep their real colors
var css =
"html.sd-dark{" + flip + ";background:#fff}" +
"html.sd-dark :is(" + s.keepColors + "){" + unflip + "}" +
"html.sd-dark :is(" + s.keepColors + ") :is(img,video,iframe,picture){filter:none}" +
"html.sd-dark :is(" + s.alsoInvert + "){filter:none}" +
"html.sd-dark .sddm-keep:not(header,#header){" + unflip + "}" +
"html.sd-dark :is(header,#header).sddm-keep > :not(.header-menu){" + unflip + "}" + // filter the header's parts, not the header, so the full screen mobile menu still works
"html.sd-dark :is(header,#header).sddm-keep.sddm-bgset{background-color:var(--sddm-bg)!important}" +
"html.sd-dark .header-menu.sddm-keep-menu{" + unflip + "}" +
"html.sd-dark .header-menu.sddm-keep-menu .sddm-flip{filter:none}" +
"html.sd-dark .sddm-tint :is(.header-background,.header-background-solid){opacity:0!important}" +
"html.sd-dark .sddm-keep .sddm-flip{" + flip + "}" +
"html.sd-dark .sddm-keep :is(" + s.keepColors + "),html.sd-dark .sddm-keep :is(" + s.alsoInvert + "){filter:none}" +
"html{transition:filter .3s ease}" +
".sddm-btn{position:fixed;" + side + ":" + s.side + "px;bottom:" + s.bottom + "px;z-index:9999;width:" + s.size + "px;height:" + s.size + "px;border-radius:50%;border:0;cursor:pointer;display:grid;place-items:center;background:" + s.lightButton + ";color:" + s.darkButton + ";box-shadow:0 0 0 2px " + s.darkButton + ",0 6px 20px rgba(0,0,0,.3);transition:transform .2s ease}" + // the ring keeps the button visible on light AND dark sections
".sddm-btn:hover{transform:scale(1.08)}" +
".sddm-btn:focus-visible{outline:3px solid #2F5BFF;outline-offset:3px}" +
".sddm-btn svg{width:50%;height:50%;fill:currentColor}" +
".sddm-btn .sddm-sun{display:none}" +
"html.sd-dark .sddm-btn{" + unflip + ";background:" + s.darkButton + ";color:" + s.lightButton + ";box-shadow:0 0 0 2px " + s.lightButton + ",0 6px 20px rgba(0,0,0,.3)}" +
"html.sd-dark .sddm-btn .sddm-sun{display:block}" +
"html.sd-dark .sddm-btn .sddm-moon{display:none}" +
"@media (prefers-reduced-motion:reduce){html,.sddm-btn{transition:none}}";
var style = document.createElement("style");
style.id = "sddm-styles";
style.textContent = css;
document.head.appendChild(style);
}
sukeshIsDarkColor(c) {
var m = c && c.match(/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?/);
if (!m || (m[4] !== undefined && parseFloat(m[4]) < 0.5)) return null; // transparent
var l = (0.2126 * m[1] + 0.7152 * m[2] + 0.0722 * m[3]) / 255;
return l < 0.45;
}
sukeshReverseColor(c) { // the color that shows as c once the page is flipped, used for a kept header's own background
var m = c && c.match(/rgba?\(([\d.]+),\s*([\d.]+),\s*([\d.]+)(?:,\s*([\d.]+))?/);
if (!m) return "transparent";
var r = +m[1], g = +m[2], b = +m[3], a = m[4] === undefined ? 1 : +m[4];
var f = function (v) { return Math.round(255 - Math.max(0, Math.min(255, v))); };
return "rgba(" + f(-0.574 * r + 1.43 * g + 0.144 * b) + "," + f(0.426 * r + 0.43 * g + 0.144 * b) + "," + f(0.426 * r + 1.43 * g - 0.856 * b) + "," + a + ")";
}
sukeshOwnBackground(el) {
var list = [el].concat([].slice.call(el.querySelectorAll(":scope > *, :scope > * > *")));
var box = el.getBoundingClientRect();
for (var i = 0; i < list.length; i++) {
var r = list[i].getBoundingClientRect();
if (i > 0 && (r.width < box.width * 0.9 || r.height < box.height * 0.9)) continue;
var cs = getComputedStyle(list[i]);
if (cs.visibility === "hidden" || cs.opacity === "0") continue; // skip hidden layers like a closed mobile menu
var dark = this.sukeshIsDarkColor(list[i].dataset.sddmBg || cs.backgroundColor); // sddmBg = the header's real color, saved before it was repainted
if (dark !== null) return dark;
}
return null;
}
sukeshBackground(el) {
var own = this.sukeshOwnBackground(el);
if (own !== null) return own;
for (var p = el.parentElement; p; p = p.parentElement) { // see-through section: use the color behind it
var pc = this.sukeshIsDarkColor(getComputedStyle(p).backgroundColor);
if (pc !== null) return pc;
}
return null;
}
sukeshFindDarkSections() {
if (this.s.keepDarkSections === false) return;
var self = this;
var AREAS = "section, header, footer, .page-section, #header, #footer-sections";
document.querySelectorAll(AREAS).forEach(function (el) {
if (el.matches("header, #header")) { // read a header's real color, without the repaint below
el.classList.remove("sddm-bgset");
el.dataset.sddmBg = getComputedStyle(el).backgroundColor;
}
if (el.querySelector(AREAS)) { el.classList.remove("sddm-keep"); return; } // a wrapper around other sections: let the inner sections decide
if (el.parentElement && el.parentElement.closest(".sddm-keep")) { el.classList.remove("sddm-keep"); return; }
var media = el.querySelector(".section-background img, .section-background video, [data-section-background-video], .background-video, .section-background [style*='background-image']") ||
/url\(/.test(getComputedStyle(el).backgroundImage);
var overlay = el.matches("header, #header") && self.sukeshOwnBackground(el) === null; // a see-through header sits on top of the page
var lightText = self.sukeshIsDarkColor(getComputedStyle(self.sukeshFirstText(el)).color) === false;
var keep = overlay ? lightText : (media || self.sukeshBackground(el) === true);
el.classList.toggle("sddm-keep", !!keep);
el.classList.toggle("sddm-overlay", !!(overlay && keep));
if (keep && el.matches("header, #header")) { // repaint the header's own background so it shows its real color
el.dataset.sddmBg = getComputedStyle(el).backgroundColor;
el.style.setProperty("--sddm-bg", self.sukeshReverseColor(el.dataset.sddmBg));
el.classList.add("sddm-bgset");
}
});
// The mobile menu: keep it as designed when it is dark, let it turn dark when it is light
document.querySelectorAll(".header-menu").forEach(function (m) {
var bg = m.querySelector(".header-menu-bg") || m;
m.classList.toggle("sddm-keep-menu", self.sukeshIsDarkColor(getComputedStyle(bg).backgroundColor) === true);
});
// A see-through header over a section that turned dark: hide its light tint so the menu sits on the dark page
document.querySelectorAll(".sddm-overlay").forEach(function (h) {
var b = h.getBoundingClientRect();
var under = document.elementFromPoint(b.left + b.width / 2, Math.min(b.bottom + 5, window.innerHeight - 1));
var tint = !!(under && !h.contains(under) && !under.closest(".sddm-keep"));
h.classList.toggle("sddm-tint", tint);
h.querySelectorAll("a, button").forEach(function (btn) { // dark buttons would vanish on the dark page: flip them to light
btn.classList.toggle("sddm-flip", tint && !btn.closest(".header-menu") && self.sukeshIsDarkColor(getComputedStyle(btn).backgroundColor) === true);
});
});
}
sukeshCheckLogo() {
if (!this.s.logo) return;
document.querySelectorAll(this.s.logo).forEach(function (img) {
if (img.dataset.sddmChecked) return;
img.dataset.sddmChecked = "1";
var test = new Image();
test.crossOrigin = "anonymous";
test.onload = function () {
try {
var c = document.createElement("canvas");
c.width = c.height = 24;
var x = c.getContext("2d");
x.drawImage(test, 0, 0, 24, 24);
var p = x.getImageData(0, 0, 24, 24).data, n = 0, lum = 0, sat = 0;
for (var k = 0; k < p.length; k += 4) {
if (p[k + 3] < 128) continue; // ignore transparent pixels
var r = p[k] / 255, g = p[k + 1] / 255, b = p[k + 2] / 255;
var hi = Math.max(r, g, b), lo = Math.min(r, g, b);
lum += 0.2126 * r + 0.7152 * g + 0.0722 * b;
sat += hi ? (hi - lo) / hi : 0;
n++;
}
if (n && lum / n < 0.35 && sat / n < 0.25) img.classList.add("sd-invert"); // black or dark gray logo: flip it to white
} catch (e) {} // image could not be read: keep its real colors
};
test.src = img.currentSrc || img.src;
});
}
sukeshFirstText(el) {
var items = el.querySelectorAll("h1, h2, h3, h4, p, a, li, span");
for (var i = 0; i < items.length && i < 40; i++) {
if (items[i].offsetWidth && items[i].textContent.trim()) return items[i];
}
return el;
}
sukeshBuildButton() {
var path = window.location.pathname;
var hidden = (this.s.hideOn || []).some(function (p) { return path.indexOf(p) === 0; });
if (hidden || document.body.classList.contains("sqs-edit-mode")) { root.classList.remove("sd-dark"); return; }
var self = this;
this.sukeshFindDarkSections();
this.sukeshCheckLogo();
window.addEventListener("load", function () { self.sukeshFindDarkSections(); self.sukeshCheckLogo(); });
window.addEventListener("mercury:load", function () { self.sukeshFindDarkSections(); self.sukeshCheckLogo(); });
var waiting = false; // headers often change color on scroll, so re-check (at most every 250ms)
window.addEventListener("scroll", function () {
if (waiting || !root.classList.contains("sd-dark")) return;
waiting = true;
setTimeout(function () { waiting = false; self.sukeshFindDarkSections(); }, 250);
}, { passive: true });
var btn = document.createElement("button");
btn.className = "sddm-btn";
btn.type = "button";
btn.innerHTML =
'<svg class="sddm-moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"/></svg>' +
'<svg class="sddm-sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="5"/><path d="M12 1v3M12 20v3M4.2 4.2l2.1 2.1M17.7 17.7l2.1 2.1M1 12h3M20 12h3M4.2 19.8l2.1-2.1M17.7 6.3l2.1-2.1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';
btn.addEventListener("click", function () {
self.sukeshApply(root.classList.contains("sd-dark") ? "light" : "dark", true);
});
this.btn = btn;
document.body.appendChild(btn);
this.sukeshApply(root.classList.contains("sd-dark") ? "dark" : "light", false);
}
}
new SukeshDasDarkMode(window.SukeshDasDarkModeSettings);
})();
</script>
The SETTINGS section at the top is the only part you edit. Underneath it, the SukeshDasDarkMode class applies the saved or system theme before the page appears, adds the styles, and builds the toggle button with a moon and sun icon.
The toggle is hidden while you are editing in Squarespace, so it never gets in the way of the editor, and dark mode is switched off there so you always edit your real colors.
How do I customize the Squarespace dark mode toggle?
| Setting | What it does | Example |
|---|---|---|
followSystem | Start in dark mode when the visitor’s device is set to dark | true |
remember | Remember each visitor’s choice for next time | true |
position | Which bottom corner the button sits in | "left" or "right" |
bottom / side | Distance from the screen edges in pixels | 20 |
size | Button size in pixels | 44 |
lightButton | Button color while the site is light | #0A0B0F |
darkButton | Button color while the site is dark | #F2F4F7 |
keepDarkSections | Leave sections that are already dark, or use a photo or video background, exactly as designed | true |
keepColors | Elements that keep their real colors in dark mode | Photos, videos, maps |
logo | Your logo. A black logo turns white in dark mode, a colored logo keeps its colors | .header-title-logo img |
alsoInvert | Things that should turn dark too, like black icons or the booking calendar | .sd-invert |
hideOn | Pages where the toggle is hidden | ["/checkout"] |
Follow the visitor’s device setting
By default (followSystem: false), every visitor first sees your site exactly as you designed it, light or dark, and dark mode only turns on when they tap the button. With followSystem: true, a visitor whose phone or computer is set to dark mode sees your site in dark mode on their first visit. This uses the browser’s prefers-color-scheme setting. Set it to false if you want everyone to start in light mode and choose dark mode themselves.
Remember each visitor’s choice
With remember: true, the Squarespace dark mode toggle saves the visitor’s choice in their own browser. When they come back, the site opens in the mode they picked last time. Nothing is sent to a server and no cookie banner is needed for this kind of preference storage in most cases, but check the rules that apply to your region.
Make your logo flip correctly
You do not need to set anything for your logo. The code looks at your logo image when the page loads: a black or dark gray logo turns white in dark mode so it stays visible, while a colored or white logo keeps its real colors. If your header sits on a photo, the logo stays exactly as you designed it.
The menu is handled the same way. Menu links, the cart icon and header buttons always end up readable, including the full screen mobile menu. If you have other black images that should turn white, such as a signature or black icons, add the class sd-invert to them or add their selector to alsoInvert.
Keep certain sections exactly as they are
Add any element to keepColors and it will look the same in both modes. For example, to keep one hero section untouched, find its section ID and add it to the list:
/* Keep one section unchanged in dark mode, by Sukesh Das, sukeshdas.com */
keepColors: "img, video, iframe, picture, [style*='background-image'], section[data-section-id='PASTE-SECTION-ID']",
To find a section ID, right-click the section on your live site, choose Inspect, and look for data-section-id. My guide to fixing Squarespace mobile issues shows this step in more detail.
Should your Squarespace site have dark mode at all?
Dark mode is a preference, not a requirement. Many visitors like it for reading at night, on OLED phones, or because bright screens tire their eyes. Others never touch it. A Squarespace dark mode toggle respects both groups, because nothing changes unless a visitor asks for it or their device is already set to dark.
It suits portfolios, blogs, tech and creative brands, and any site people read for a long time. It matters less for a one page local business site where visitors stay for thirty seconds to find a phone number. If you are unsure, add it with followSystem: true and let visitors decide.
How should I test the Squarespace dark mode toggle before going live?
Spend ten minutes on these checks after adding the Squarespace dark mode toggle:
- Open your site in a private window, tap the toggle, and scroll through every main page in dark mode.
- Check your logo, buttons, forms and any embedded booking calendar or map.
- Reload the page and confirm it stays dark, which shows the remember setting works.
- Switch your phone to dark mode, open the site in a fresh private tab, and confirm it starts dark.
- Check a product page and the cart if you sell online, then add those pages to
hideOnif anything looks wrong.
Fix what you find with keepColors, alsoInvert or the small CSS fixes above. Most sites need one or two tweaks at most.
Dark mode design tips for Squarespace sites
- Use transparent PNG or SVG logos. A logo with a white box behind it looks odd on a dark background. A transparent file flips cleanly.
- Avoid text inside images. Text baked into a photo keeps its colors, so a dark caption on a photo can become hard to read. Use real text blocks instead.
- Check light gray text. Very pale gray text flips to very dark gray, which can have weak contrast. Slightly darker grays flip into better light grays.
- Keep brand photos bright. Photos keep their real colors, so they stand out nicely against dark sections.
Can I put the Squarespace dark mode toggle in the header?
The floating button is the most reliable option because it works with every header layout. If you prefer the toggle near the top of the screen, add this to Custom CSS. It moves the Squarespace dark mode toggle to the top right corner, just below the header:
/* Move the dark mode toggle to the top, by Sukesh Das, sukeshdas.com */
.sddm-btn {
top: 90px;
bottom: auto !important;
}
@media screen and (max-width: 767px) {
.sddm-btn { top: 76px; width: 40px; height: 40px; }
}
Adjust the top value to sit just below your header height, and set position: "right" in the settings if you want it on the right.
How do I fix things that look wrong in dark mode?
Because the colors flip, a few details can look different from what you expect. These are the common ones and their fixes:
- Shadows turn into glows. A soft dark shadow becomes a light glow in dark mode. Most sites look fine, but you can remove shadows in dark mode with the CSS below.
- Brand colors look slightly different. A blue button becomes a lighter blue. That is the natural dark equivalent, and it keeps good contrast on dark backgrounds.
- An embedded widget looks odd. Maps and videos keep their real colors, and the Squarespace Scheduling calendar turns dark with the page. For another booking tool that stays white, add its iframe to
alsoInvert, for exampleiframe[src*='calendly.com']. - Bright yellow looks softer. This is a known limit of the color flip technique. If yellow is a key brand color, test it, or consider a custom dark theme.
/* Dark mode detail fixes, by Sukesh Das, sukeshdas.com */
/* Remove shadows that turn into glows */
html.sd-dark .sqs-block-button-element,
html.sd-dark .fe-block {
box-shadow: none !important;
}
/* Soften pure white text a little in dark mode */
html.sd-dark body {
opacity: 0.96;
}
Does this Squarespace dark mode toggle work on other website builders?
Yes. The code is plain JavaScript and CSS, so it works on WordPress, Shopify, Webflow, Wix and hand-coded sites too. Paste it into the area that loads inside the page <head>: the WPCode plugin’s Header box on WordPress, theme.liquid before </head> on Shopify, or Head code in Webflow’s site settings.
On those platforms, change the logo setting to your own logo selector, because the default class names are specific to Squarespace.
Does a Squarespace dark mode toggle affect SEO or accessibility?
It does not affect SEO. Search engines read your content the same way in both modes, and the toggle adds no extra pages or content. The code is small and loads nothing from other servers, so it does not slow your site down.
For accessibility, the button has a clear label that changes between “Switch to dark mode” and “Switch to light mode”, and it reports its state to screen readers. It can be used with the keyboard and shows a visible focus ring. Color changes also stop animating for visitors who prefer reduced motion. You can check text contrast in both modes with the free WebAIM contrast checker.
Does it work on store, booking and blog pages?
Yes. I tested this Squarespace dark mode toggle on regular pages, the store page, product pages, the cart, a blog and a Squarespace Scheduling booking page. Product photos keep their real colors, prices and buttons stay readable, and the booking calendar turns dark to match the page. The header logo and menu, including the mobile menu, stay readable in every case.
Two places stay in their normal colors: Squarespace checkout, because Squarespace does not load custom code there, and the Squarespace editor, where the toggle is hidden on purpose so you always edit your real design.
Why is my Squarespace dark mode toggle not working?
- No button appears. Check that your plan includes Code Injection and that you pasted the full code, including both
<script>tags. The button does not show inside the Squarespace editor, so check your live site. - The page flashes white before turning dark. The code is in the Footer box. Move it to the Header box.
- My logo disappeared in dark mode. Make sure the
logosetting matches your logo. On Squarespace the default works. On other platforms, change it to your own logo selector. - My photos look strange. A photo may be set as a CSS background in a way the code does not detect. Add its section or element to
keepColors. - Text is hard to read in a dark section. Make sure
keepDarkSectionsistrueand that you use the latest version of the code above. If one custom section is still missed, add its section ID tokeepColorsas shown earlier. - The site opens dark for some visitors. That is
followSystemworking: their device is set to dark mode. Set it tofalseif you prefer. - Other code stopped working after an update. See my guide on why Squarespace code stops working.
When should you get a custom dark theme instead?
This free Squarespace dark mode toggle is perfect when you want a quick, clean dark version of your whole site. A custom dark theme is better when your brand needs exact colors in dark mode, when you want different images in each mode, or when you want the switch styled into your header as part of the design.
In a custom build, I define a matching dark color for every element, so headings, buttons, cards and backgrounds look exactly as planned in both modes. If that is what you need, send me a short brief.
Want a ready-made snippet for this?
These snippets from my free library each come with a live preview, copy-ready code and settings you can change:
Browse all of them in the free Squarespace snippet library.
Squarespace dark mode toggle FAQs
Does Squarespace have a Squarespace dark mode toggle?
No. Squarespace lets you design a dark site with color themes, but it has no built-in switch for visitors. You can add one with the free code in this guide.
Is this Squarespace dark mode toggle free?
Yes. The code is free. You only need a plan that includes Code Injection, such as Core, Plus or Advanced.
Where do I paste the dark mode code in Squarespace?
In Website, Pages, Custom Code, Code Injection, inside the Header box. The header placement stops the page from flashing white for visitors who chose dark mode.
Will my photos look inverted in dark mode?
No. The code flips photos, videos, maps and background images back, so they keep their real colors.
Can dark mode follow the visitor’s phone setting?
Yes. With followSystem set to true, visitors whose device is in dark mode see your site in dark mode on their first visit.
Does the toggle remember the visitor’s choice?
Yes. With remember set to true, the choice is saved in the visitor’s browser and used on their next visit.
How do I stop my logo from disappearing in dark mode?
You do not need to do anything. The code checks your logo automatically: a black or dark gray logo turns white in dark mode, and a colored logo keeps its colors.
Does a Squarespace dark mode toggle hurt SEO?
No. Search engines read the same content in both modes, and the code is small and loads no outside files.
Does this work on WordPress or Shopify?
Yes. Paste the code into the head of your site, for example with the WPCode plugin on WordPress or in theme.liquid on Shopify, and update the logo selector.
Want dark mode added for you?
If you would rather not touch code, I can add the Squarespace dark mode toggle to your site, fine-tune it for your logo and colors, and test it on real phones. I build and support Squarespace sites every week as a Squarespace web designer. Send me a short brief and I will reply within one working day.
Related guides: Squarespace header CSS, Squarespace logo slider and free floating WhatsApp button.

