The discussion revolves around adding specific CSS for dark mode in Discourse, particularly for external widgets like a leaflet map. merefield asks if it’s still not possible to target dark mode directly via CSS without a dedicated class. awesomerobot suggests using @if #{schemeType()} == dark in color_definitions.scss to apply styles conditionally, and explains how to implement this in a Theme Component or Plugin. merefield clarifies that a class isn’t necessary as long as CSS can distinguish between light and dark modes, and awesomerobot provides guidance on where to add the code, including via the admin panel’s CSS section as shown in the screenshot.
I’d like to add specific CSS for an external widget (a leaflet map) when dealing with a dark theme, is it still not possible to identify using just a CSS selector?
Of course I can just create a Theme Component to apply the changes and assume the admin just adds that to the Dark Scheme, but that won’t switch automatically … (which is the current solution)
In a remote theme or component you can create a file common/color_definitions.scss — if you’re looking to add CSS via the admin panel there’s a section there: