ダークモードの使用を検出する方法はありますか?

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?

「いいね!」 3

Hello,

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.

「いいね!」 3

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.

「いいね!」 2

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

document.body.classList.add(“dark-theme”);

document.body.classList.add(“light-theme”);

Thanks for your inputs @Don @Lilly

「いいね!」 2

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