Dynamically setting a color variable conditioned on the light/dark theme for use in custom css #9640
Unanswered
chiragraman
asked this question in
Q&A
Replies: 1 comment 6 replies
-
Update: Following #6307 and this discussion on Stack Overflow, I tried adding the following in .quarto-light {
$cr-body-bg-1: $cr-body-bg-light !global;
}
.quarto-dark {
$cr-body-bg-1: $cr-body-bg-dark !global;
} This still doesn't work. I'm not sure if I'm missing something basic about css/sass or am going down the wrong rabbit hole. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Hi Quarto community!
I'm building a website with Quarto and need some custom css for one of the pages. I've been keeping my color variables in a separate file that I import into the custom CSS file for the page, and would appreciate any insights on how I might correctly set the variables such that things work for both light and dark mode.
The setup
Part of my current file structure looks like this:
about > index.qmd
front-matter as follows:assets/style/colors.scss
I'm defining variables for my custom color palette with the customcr-
prefix. Following some of the discussion here, I also created CSS variables for one of the variables for use in the custom CSS file. Here's an example:assets > about.css
I am referencing the custom variable like so:The Questions
The setup works for a single theme, but the value of
$cr-body-bg
obviously won't update when the theme is toggled from dark to light, where I would like it to change to the value of$cr-body-bg-light
from$cr-body-bg-dark
. Concretely, I have the following questions I'd appreciate any help with:$cr-body-bg
somewhere upstream depending on whether the current theme is light or dark, without needing to change anything inassets > about.css
? If not, is there an alternative method to get the result I am going for?-light
and-dark
suffixes and dynamically setting some other variable's value to these?Thanks for your help!
Other information
Quarto version: 1.4.553, on a Macbook.
Beta Was this translation helpful? Give feedback.
All reactions