Skip to content

Code Block Themes

About 409 wordsAbout 1 min

2026-09-01

Post code block syntax highlighting is powered by Expressive Code, with light and dark themes configured in expressiveCodeConfig.ts, switching automatically with the site's dark mode.

Configuration

src/config/expressiveCodeConfig.ts
export const expressiveCodeConfig = withUserConfig("expressiveCode", {
  theme: "github-dark",
  lightTheme: "github-light",
  darkTheme: "github-dark",
})
FieldDefaultDescription
themegithub-darkBase theme (fallback for compatibility scenarios)
lightThemegithub-lightCode theme in light mode
darkThemegithub-darkCode theme in dark mode

The build generates styles for both light and dark themes; pages switch automatically with the visitor's mode choice—no client scripts involved.

Available Themes

Theme names come from the Shiki theme library. Popular choices:

ThemeStyle
github-light / github-darkDefault. GitHub style, neutral and readable
catppuccin-latte / catppuccin-mochaSoft macaron palette, fits anime aesthetics
one-light / one-dark-proClassic editor style
draculaHigh-saturation purple
rose-pine-dawn / rose-pineLow-saturation rose tones
vitesse-light / vitesse-darkLow-contrast, easy on the eyes

For the full list see the Expressive Code / Shiki theme documentation.

Pairing Suggestions

Echo the site's colors (recommended for anime sites)

src/config/expressiveCodeConfig.ts
{
  theme: "catppuccin-mocha",
  lightTheme: "catppuccin-latte",
  darkTheme: "catppuccin-mocha",
}

Low-contrast comfort combo

src/config/expressiveCodeConfig.ts
{
  theme: "vitesse-dark",
  lightTheme: "vitesse-light",
  darkTheme: "vitesse-dark",
}

Relation to Dynamic Colors

Code block themes are fixed palettes and do not participate in HCT dynamic coloring—changing themeColor.hue does not alter code highlight colors. For visual harmony, pick a Shiki theme close to your site's seed color (e.g. rose-pine themes for pink/purple sites).

Code block syntax capabilities (file trees, code trees, line decorations, collapsing) are covered in Code Display(Open in new window) in the Writing section; this page is only about color themes.

FAQ

The theme change has no effect

The code block background clashes with the card background

Can code blocks follow the theme color