How to enable a different (light) code block theme when the website theme changes? #244
-
When the site theme is toggled to 'light', the syntax-highlighted code blocks remain dark-themed. |
Beta Was this translation helpful? Give feedback.
Answered by
FjellOverflow
Jan 22, 2024
Replies: 1 comment
-
The default syntax-highlighter Shikiji can be configured to have multiple themes in shikiConfig: {
- theme: "github-dark",
+ experimentalThemes: {
+ dark: "github-dark",
+ light: "github-light",
},
wrap: true,
} The respective light/dark themed syntax-highlighting is set by adding CSS, for instance in html[data-theme="dark"] .astro-code,
html[data-theme="dark"] .astro-code span {
color: var(--shiki-dark) !important;
background-color: var(--shiki-dark-bg) !important;
font-style: var(--shiki-dark-font-style) !important;
font-weight: var(--shiki-dark-font-weight) !important;
text-decoration: var(--shiki-dark-text-decoration) !important;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
satnaing
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The default syntax-highlighter Shikiji can be configured to have multiple themes in
astro.config.ts
:The respective light/dark themed syntax-highlighting is set by adding CSS, for instance in
src/styles/base.css
: