.dark .element
for dark styles and apply them when the dark
class is added to <body>
.dark
class on click.localStorage
to remember the user’s dark mode preference.To enable a dark mode toggle in Webflow (as of 2020), you need to use a combination of Webflow interactions (triggers) and custom classes or attributes to switch between light and dark styles.
.dark h1
, .dark .button
, etc.<body>
) has the class dark
, nested elements will show the dark version.dark-mode-toggle
.dark
class to the <body>
(or main wrapper).dark
class..dark
Classdark
class temporarily, and style nested elements accordingly under these selectors (e.g., .dark .section
, .dark .nav
, etc.).dark
is added to <body>
, only the dark styles apply.Webflow’s native functionality (in 2020) doesn't support storing user preferences. To persist dark mode:
localStorage
to save the user’s mode and detect it on page load (e.g., localStorage.setItem('mode', 'dark')
).dark
class accordingly.To enable dark mode in Webflow in 2020, use a toggle interaction to add/remove a dark
class on the body or wrapper element, then use combo classes or nested selectors to define dark styles. Optionally, use custom code to store the user’s preference.