Skip to content

Docs: fix Shiki dark mode rendering#42591

Merged
julien-deramond merged 1 commit into
v6-devfrom
v6-dev-jd-fix-shiki-dark-mode-rendering
Jun 28, 2026
Merged

Docs: fix Shiki dark mode rendering#42591
julien-deramond merged 1 commit into
v6-devfrom
v6-dev-jd-fix-shiki-dark-mode-rendering

Conversation

@julien-deramond

@julien-deramond julien-deramond commented Jun 28, 2026

Copy link
Copy Markdown
Member

Closes #42566

Description

In dark mode, structural tokens inside certain code blocks were rendered as near-black and therefore invisible against the dark background. This was specifically visible in the <script type="importmap"> example on the Install page, where the JSON structure characters ({, }, :) would disappear.

The site has two code rendering paths:

  • <Code> tab components — use highlight.ts, which already passes defaultColor: 'light-dark()' to Shiki.
  • Markdown fenced code blocks — use Astro's built-in Shiki integration configured in astro.config.ts, which was missing defaultColor: 'light-dark()'.

Without it, Shiki defaults to defaultColor: 'light', generating color: var(--shiki-light) for all uncolored/structural tokens. The Bootstrap VS Code light theme's editor.foreground is #0b0c0d (near-black), which is fine on a light background but invisible in dark mode.

Explicitly colored tokens (strings, property names, tags) were unaffected because their spans carry both --shiki-light and --shiki-dark CSS variables. Only tokens falling back to the default foreground were broken.

The fix is rather simple: add defaultColor: 'light-dark()' to the shikiConfig in astro.config.ts, consistent with highlight.ts.

With this option, Shiki emits color: light-dark(var(--shiki-light), var(--shiki-dark)) for default-colored tokens. The CSS light-dark() function reads the color-scheme property, which Bootstrap already sets to dark on [data-bs-theme="dark"], so the correct dark foreground (#f6f7f8) is applied automatically.

New rendering:

Before the fix Now
Screenshot 2026-06-28 at 10 42 06 Screenshot 2026-06-28 at 10 42 53

Live previews

@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Jun 28, 2026
@julien-deramond julien-deramond linked an issue Jun 28, 2026 that may be closed by this pull request
@julien-deramond julien-deramond marked this pull request as ready for review June 28, 2026 08:43
@julien-deramond julien-deramond merged commit 55d22aa into v6-dev Jun 28, 2026
12 checks passed
@julien-deramond julien-deramond deleted the v6-dev-jd-fix-shiki-dark-mode-rendering branch June 28, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

Docs: syntax highlighter black text color in dark mode

1 participant