Skip to content

Design6 min read

How do you set up dark mode in Webflow?

Learn how to create a dark mode in Webflow with CSS variables, a toggle button, and localStorage to remember the user’s choice.

In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to create a dark mode in Webflow using CSS variables and localStorage.

Example

Webflow development

From mockup to live website

SEO & GEO

Google visibility and AI search engines

CRO & Growth

Conversion rate optimization

StepActionTool
1Set up CSS variables for colorsWebflow Variables
2Create a dark variant in the variablesWebflow Variables
3Add a toggle buttonWebflow Designer
4Script to switch and remember the modeJavaScript + localStorage

1. Define your CSS variables in Webflow

In the Designer, go to Variables. Create color variables: --color-bg, --color-text, --color-surface. Assign these variables to all your elements (backgrounds, text, borders) instead of using direct colors.

2. Create the "dark-mode" class on the body

Add a CSS embed with the dark values for your variables:

body.dark-mode {
  --color-bg: #0f0f0f;
  --color-text: #f5f5f5;
  --color-surface: #1a1a1a;
}

3. Add a toggle button

Create a button in Webflow and assign it the ID theme-toggle.

4. Add this script in the <body>

const toggle = document.getElementById('theme-toggle');
const saved = localStorage.getItem('theme');
if (saved === 'dark') document.body.classList.add('dark-mode');
toggle.addEventListener('click', function() {
  document.body.classList.toggle('dark-mode');
  localStorage.setItem('theme',
    document.body.classList.contains('dark-mode') ? 'dark' : 'light'
  );
});

Conclusion

Dark mode improves reading comfort and matches modern user preferences. Use cases:

  • Documentation sites or technical blogs
  • SaaS tools and dashboards
  • Creative websites with a strong visual identity

Published on May 19, 2026

Sandro DA SILVA

Growth Marketer, Webflow expert, and jack-of-all-trades. Sandro handles commercial operations, ensures projects run smoothly, and addresses marketing-related issues (SEO, Tracking, Copywriting, etc).

You're going to working with us, guaranteed

Ready to launch your business?

get a quote

Let’s f*****G GO !!