No specific class for dark mode

Continuing the discussion from How to add a specific body class for the dark (or light) mode?:

Is this still the case?

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)

5 Likes

Would this accomplish what you need? this would need to be added to color_definitions.scss

@if #{schemeType()} == dark {
    body {
        background: red;
    }
} @else {
     body {
        background: blue;
    } 
}

A class does seem like it would be useful though, we can probably add one.

4 Likes

Thanks for your suggestion.

Yeah, doesn’t need to be a class so long as I can distinguish in CSS.

Dumb question: how can I do that from within a Theme Component or Plugin?

3 Likes

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:

Screenshot 2023-02-13 at 10.55.17 AM

4 Likes

Thanks @awesomerobot!

3 Likes

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