Dark Mode Indicator

Can Glide create an experimental column that simply displays a read-only boolean check box if dark mode is on? This would be helpful so that gliders can create if/then statements and filters based on that to control certain components when it changes from light to dark mode.
I think someone has asked for a switch in the past but this wouldn’t be controlled by user input. If anyone has a workaround, please let me know!

Add the following in a javascript column. To ensure that the value updates if a user changes their theme after the app is opened, add the current time as a parameter. This will be enough for the code to trigger every ten seconds and check the device theme.

function isDarkMode() {
    return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
}

if (isDarkMode()) {
    return true;
} else {
    return false;
}

3 Likes