Skip to content

fix(ui): make code blocks follow the theme in dark mode - #38771

Merged
ryan-crabbe-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_/api-reference-dark-mode-4ec67f
Aug 29, 2026
Merged

ryan-crabbe-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_/api-reference-dark-mode-4ec67f

Conversation

@yuneng-berri

@yuneng-berri yuneng-berri commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Code blocks are unreadable in dark mode
  • White card behind a dark box on every line

How it solves it:

  • Code surface no longer paints its own background
  • The block inherits the themed surface around it

User Flow

Before: an admin browsing the dashboard in dark mode finds the code samples hard to read

  1. They open http://localhost:4000/ui/?page=api-reference and switch the theme toggle in the top bar to dark
  2. The page turns dark, but the sample code sits on a near white card
  3. Each line of code has its own dark rectangle painted behind the text, sized to the text, so the block reads as stripes rather than one panel
  4. The same thing happens on the Cost Tracking page and on the usage snippet in a routing group's detail view, since they show the same kind of code block

After: the same admin sees one dark code panel that matches the rest of the page

  1. They open http://localhost:4000/ui/?page=api-reference and switch the theme toggle to dark
  2. The sample code sits on a single dark panel, with the light syntax colors on top of it and no white card behind
  3. There are no per line rectangles; the block reads as one surface
  4. Switching the toggle back to light gives the same panel in light gray, with the copy button still visible in the corner
  5. Cost Tracking and the routing group usage snippet pick up the same behavior

Relevant issues

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Setup: local proxy plus the dashboard dev server pointed at it, signed in as an admin, page http://localhost:3103/api-reference with the theme toggle set to dark

Before (f0fadb7)

  1. Open the API Reference page in dark mode
  2. Observed: white card behind the samples, and a dark rectangle hugging each line of code

After (8f07a12)

  1. Open the same page in dark mode
  2. Observed: one dark code panel, no white card, no per line rectangles
  3. Flip the theme toggle to light
  4. Observed: one light gray panel with dark syntax text, copy button still visible
image

Type

🐛 Bug Fix

Caveats (if any)

Low

  • Copy button restyled so it reads on both surfaces

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

… mode

The customStyle background only reaches the <pre>, so the prism theme's own
background stayed on the inner <code>. In dark mode that left a white card
with a dark box hugging every line. Let the block inherit the themed surface
from its wrapper instead.
@greptile-apps

greptile-apps Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates the shared dashboard code block to inherit themed surfaces instead of painting fixed highlighter backgrounds.

  • Adds a muted background to the code block container.
  • Makes highlighter and inner code backgrounds transparent.
  • Restyles the copy control for visibility across light and dark themes.

Confidence Score: 5/5

The PR appears safe to merge, with the themed code surface and copy control remaining readable in supported light and dark modes.

The shared component now exposes the container’s theme-aware muted background while retaining syntax-theme foreground colors, and the copy button has distinct surface, border, icon, and hover tokens in both themes.

Important Files Changed

Filename Overview
ui/litellm-dashboard/src/components/CodeBlock.tsx Replaces fixed code backgrounds with theme-aware surfaces and updates the copy button without introducing an actionable defect.

Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile

@ryan-crabbe-berri
ryan-crabbe-berri merged commit e585aab into litellm_internal_staging Aug 29, 2026
76 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_/api-reference-dark-mode-4ec67f branch August 29, 2026 17:39
galactic-batter Bot pushed a commit to codgician/litellm that referenced this pull request Sep 1, 2026
…dark-mode-4ec67f

fix(ui): make code blocks follow the theme in dark mode

(cherry picked from commit e585aab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants