Custom CSS light/dark mode switching #3249
-
I have written some very basic code to customize the bg color of alternate rows in table so that it looks like this: This works great in light mode but I can't figure out how to have access to a dynamic bg color var in plain css. I attempted to compile as SCSS so that I could use similar if logic that is used in the main theme itself, but the build ignored the file.
This code doesn't work and the browser tells me it's an unknown property. So my question is, how do I access the "state" of the color theme in the CSS that we can include in a build as "extra"? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
In order to compile SCSS, you need to set up the theme development process (mentioned in the customization guide). Other than that, you might just use regular CSS. If you're using [data-md-color-scheme="slate"] .md-typeset__table tr:nth-child(2n) {
background-color: red; /* Just for demonstration purposes */
} Adding this as extra CSS, this will only be applied if the dark theme is active. |
Beta Was this translation helpful? Give feedback.
In order to compile SCSS, you need to set up the theme development process (mentioned in the customization guide). Other than that, you might just use regular CSS. If you're using
slate
as a dark theme, just prefix your rules accordingly:Adding this as extra CSS, this will only be applied if the dark theme is active.