Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Dark Mode Toggle

Security covered Under active development 1,609 sites

This module provides a block that allows website visitors to easily switch between light and dark modes, or follow their system's preference, with their choice remembered across sessions.

When your theme supports dark mode, this module provides a block that allows visitors to toggle between the light and dark variants.

The Dark Mode Toggle block features three buttons:

  • Light: switches to the light mode.
  • Dark: switches to the dark mode.
  • System: follows the user's browser preference.

The user's choice is saved in the browser's local storage, so their preference
is remembered when navigating pages, or they return to the site.

When dark mode is preferred, this module sets the data-dmt-mode attribute to dark on the <html> element (or light for light mode). Additionally, a data-dmt-source attribute is added to indicate the source of the dark mode choice, which can either be user or system. It is up to the theme to style the site correctly based on the selected variant.

Note: the 1.0 version of this module applied the dark class to the <html> element. In the 2.0 version of this module, we switched to using data attributes to handle state and behavior.

Post-Installation

To set up the Dark Mode Toggle block, navigate to Administration » Structure » Block layout and place it in one of the available regions. The basic Twig template dark-mode-toggle.html.twig provides the block's content, which can be overridden in a custom theme.

Similar projects

  • Darkmode JS, uses the Darkmode.js library to automatically provide dark mode support using the CSS mix-blend-mode. Since colors are automatically computed, you have limited control of the exact styling for the dark variant.
  • Dark Mode, switches between two separate themes based on the time of the day.
  • Dark Mode Switch, uses a checkbox to toggle a class attribute. However, there is no option to base the dark mode on the system's preference and no countermeasure against FOUC.
  • Dark Mode Button, toggle a class attribute to indicate dark mode. The system's preference is not taken into account, and there is no countermeasure against FOUC.
Drupal 11 · not 10

Ask your assistant about Dark Mode Toggle

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
8
Tracked since
Dec 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 8
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.0.1 Stable 11 Oct 9, 2025
2.0.0 Stable 11 Oct 6, 2025
2.x-dev Dev 11 Sep 28, 2025
1.0.0 Stable 10–11 Feb 3, 2025
1.0.0-alpha3 Pre-release 10–11 Jan 2, 2025
1.0.0-alpha2 Pre-release 10–11 Dec 31, 2024
1.0.0-alpha1 Pre-release 10–11 Dec 28, 2024
1.x-dev Dev 10–11 Dec 28, 2024