The text color and color of the headings change as expected, but --background-primary has no effect.
I realize that I could do
body .myclass {
background-color: #0f0f23;
}
which does change the background, but this breaks the style in multiple ways:
in editing mode, the cursor is not visible, independent of whether the rest of obsidian is in dark or light mode
in preview mode, callouts vanish completely if obsidian is in light mode
These things make no sense to me so my question is: how can I change the color of the background in a snippet, ideally using CSS variables, without breaking random other elements?
I haven’t seen a custom cssclass used with semantic colors before, but
body {
--background-primary: orange;
}
works fine --background-primary is defined differently for light and dark themes and used all over the place, so even with a cssclass, it may affect more than you would like.
Instead of the body element, I would use .theme-dark to narrow down your .myclass so that it’s not spilling into the light theme, etc. That should get closer to where you want to be, I think.
I’d recommend making a copy of the app.css (open the developer tools → Sources at the top → copy & paste it into a file) for yourself and start poking around if you are interested. A great guide is here if you haven’t seen it yet.
yeah, setting --background-primary in body {.. works (minus the callout issue) but setting it in body .myclass {... it does not have any effect.
the thing is that I want certain notes to have that dark blue background no matter whether obsidian is in dark or light theme, so I’d have to add background-color: #0f0f23; to .theme-light .myclass { ... as well, which again breaks callouts (if in light mode and preview mode).
I guess I really have to fix it “manually” – thanks for the pointer to app.css!
Got it. So callouts have blend modes ( --callout-blend-mode: ) depending on the light or dark theme. Forcing a dark background in the light theme messes that up. If we have them always follow what’s set for the dark theme in your .myclass, they should be alright without separating out theme-light and theme-dark.
The only strange thing I noticed was the text in Properties view being muted in the light theme. Added a quick fix for the time being.