Skip to content

Instantly share code, notes, and snippets.

@anurag-roy
Last active April 24, 2023 15:43
Show Gist options
  • Save anurag-roy/1dfaf64816524a80bb82c537a4a7b054 to your computer and use it in GitHub Desktop.
Save anurag-roy/1dfaf64816524a80bb82c537a4a7b054 to your computer and use it in GitHub Desktop.
GitHub theme for Shiki using css variables (supports light/dark mode switching). Can be used in Next.js, Nextra, Astro, etc.
:root {
/* Light Theme */
--shiki-color-text: #24292f;
--shiki-color-background: #f6f8fa;
--shiki-token-constant: #0550ae;
--shiki-token-string: #0a3069;
--shiki-token-comment: #6e7781;
--shiki-token-keyword: #cf222e;
--shiki-token-parameter: #116329;
--shiki-token-function: #8250df;
--shiki-token-string-expression: #0a3069;
--shiki-token-punctuation: #212121;
--shiki-token-link: #0a3069;
}
.dark {
/* Dark Theme */
--shiki-color-text: #c9d1d9;
--shiki-color-background: #161b22;
--shiki-token-constant: #79c0ff;
--shiki-token-string: #a5d6ff;
--shiki-token-comment: #8b949e;
--shiki-token-keyword: #ff7b72;
--shiki-token-parameter: #7ee787;
--shiki-token-function: #d2a8ff;
--shiki-token-string-expression: #a5d6ff;
--shiki-token-punctuation: #212121;
--shiki-token-link: #a5d6ff;
}
pre {
background-color: var(--shiki-color-background);
}
/* Line highlight styles */
code .line.highlighted {
background-color: #d0d7de60;
--tw-shadow: 2px 0 #0969da inset;
}
.dark code .line.highlighted {
background-color: #30363d80;
--tw-shadow: 2px 0 #58a6ff inset;
}
code .line {
line-height: 1.75;
}
@anurag-roy
Copy link
Author

See example here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment