Detect Live System Darkmode

Demo to preview the plugin:

Introduction

The Detect Live System Darkmode plugin allows you to detect the system dark mode setting for a user in real-time. This plugin monitors the user’s system preferences for dark mode and can trigger workflows when these settings change, without requiring a page refresh. With this plugin, you can create applications that dynamically adapt to users’ dark mode preferences, enhancing user experience and accessibility.
Image without caption

How to setup

Setting up the Detect Live System Darkmode plugin is simple:
  1. Install the plugin from the Bubble plugin marketplace.
  1. Place the ‘Detect live dark mode’ visual element on your page.
    1. Image without caption
  1. Access the element’s state ‘Dark mode?’ in your workflows to respond to the user’s dark mode setting.
    1. Image without caption
  1. Use the ‘Dark mode changed’ event to trigger workflows when the user’s system dark mode setting changes.
    1. Image without caption

Plugin Element Properties

This plugin contains a single element that acts as a detector for the user’s system dark mode preference.

Detect live dark mode

Element has not fields.
Image without caption

Exposed states

Name
Description
Type
Dark mode?
Indicates whether the user’s system is currently in dark mode. Returns ‘yes’ when dark mode is active and ‘no’ when it’s not.
Yes/No (Boolean)

Element Events

Name
Description
Dark mode changed
Triggered whenever the user’s system dark mode setting changes. This occurs when a user toggles dark mode on or off in their system settings.

Workflow example

Here’s a simple example of how to use the Detect Live System Darkmode plugin to create a dynamic theme for your application:
  1. Place the ‘Detect live dark mode’ element on your page (it can be hidden if needed after page load).
  1. Create a workflow triggered by the ‘When page is loaded’ event:
      • Action: Set a group’s style
      • Condition: When ‘Detect live dark mode’ element’s ‘Dark mode?’ state is yes
      • Set the group’s background color to a dark color and text to a light color
  1. Create another workflow triggered by the ‘Dark mode changed’ event:
      • Action: Set a group’s style
      • Condition: When ‘Detect live dark mode’ element’s ‘Dark mode?’ state is yes
      • Set the group’s background color to a dark color and text to a light color
      • Else: Set the group’s background color to a light color and text to a dark color
This workflow will automatically adapt your application’s theme based on the user’s system dark mode preference, both when the page initially loads and whenever the user changes their dark mode setting.
Image without caption

Changelogs