Is there a way to detect dark mode usage?

Is there a way in a plugin / theme component to detect if the current theme is using dark mode?
Alternately, is there a way to get the active theme ID?
Or should we create different theme components for light themes and dark themes?



I think there are a few ways to achieve this.

You can use this

Or this

Love the Discourse Ai Related Topics section :smiley: so much easier to organize and find topics.


personally i prefer having separate dark and light themes, rather than dark and light modes of a theme. i think some users find that extra drop down confusing. i just make light and dark version themes and put them in the hamburger menu, but i only have 4 live themes (i’ve done special event limited time themes though, for example we had Masters Golf light and dark themes for tournament). just have to keep track of the color pallettes.

1 Like

I resolved this by adding a single line of code to the Head section of each theme depending on the colors:



Thanks for your inputs @Don @Lilly


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.