-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shiki background colors aren't used in code blocks #734
Comments
For now, please consider overriding that variable using custom CSS. We are using different colors for light and dark mode, but material palenight doesn't have different themes for light/dark mode. That's why we can't directly use themes' bg colors. |
We must decide what to do with light/dark bg for code block before 1.0.0. Let's come back once we have conclusion, and we should close this issue too. |
Shouldn't this just use the theme's color when that is defined, otherwise a default one from the css var? |
As mentioned in the documentation(customizing-css section), we can override the css var to work around this temporarily. /* .vitepress/theme/custom.css */
html:not(.dark) {
--vp-c-text-dark-3: #ccc;
--vp-code-block-bg: rgba(238, 238, 238, 0.5);
--vp-code-line-highlight-color: rgba(238, 238, 238, 1);
} // .vitepress/theme/index.js
import DefaultTheme from 'vitepress/theme';
import './custom.css';
export default DefaultTheme; // .vitepress/config.ts
import { defineConfig } from 'vitepress'
export default defineConfig({
markdown: {
theme: {
dark: 'github-dark',
light: 'github-light',
}
}
}) Then restart your server, you can see the result. For example in the light theme: And in the dark theme: |
I have also |
Wait, does Shiki provide background color? I remember Shiki didn't had BG color so we had to add it as css var 🤔 |
Shiki's |
In that case, maybe we should be using it 🤔 What color is it? Anyone has link to example? |
During overall design refactor in #1790, I've decided to use the background color from the I'm planning to add more comprehensive docs for style customization. But meanwhile, it would be cool if we have an easy way to get the Shiki bg color so that we can show it in the docs and user can use that instead. Is there any website to lookup? where user can copy the bg color 🤔 ? |
Closing for now. If anyone finds out about the above, please let us know! |
Describe the bug
The background color for code-fences is currently set as a CSSvar but then isn't overridden when alternative Shiki themes are used.
Reproduction
solarized-light
as a Shiki thememarkdown: { theme: 'solarized-light' }
in.vitepress/config
Expected behavior
Background color changes with new themes and works with light/dark-modes.
System Info
Additional context
Example of
solarized-light
set for the themeValidations
The text was updated successfully, but these errors were encountered: