Skip to content

Keep the dark theme on example pages - #685

Merged
byronwall merged 1 commit into
mainfrom
claude/fix-672-dark-mode-examples-698a0a
Nov 22, 2026
Merged

byronwall merged 1 commit into
mainfrom
claude/fix-672-dark-mode-examples-698a0a

Conversation

@byronwall

Copy link
Copy Markdown
Owner

In dark mode on the docs site, opening an example from /examples switched the page to light. Now the theme holds on example pages, through client navigation and reloads, with no light flash. Example pages also get their own theme toggle.

Before: /examples is dark. Click an example and the workspace opens in light. A reload of the example page also shows light.
After: The example opens dark and stays dark after a reload. Light mode works the same way.

Closes #672

Cause

Only the docs layout and the site nav applied the theme, and each set the page root back to light when it unmounted. Example pages mount neither, so they always fell back to light. Nothing set the theme before the first paint on a reload.

The fix: index.html sets the theme before the first paint on every page, and the theme hook no longer reverts the root when it unmounts.

Proof

Dark system theme: open /examples, click the first example (/examples/january-flights).

Before (exploreda.dev) After (this branch)
before: example in light after: example in dark

After a reload of the example page, this branch is still dark:

after: reload stays dark

Playwright checks of the page root's dark class. The value at DOMContentLoaded shows the theme is set before the app renders, so there is no flash.

# exploreda.dev, dark system theme
examples index dark: true
example page (client nav) dark: false
after reload dark at DOMContentLoaded: false now: false

# this branch, dark system theme
examples index dark: true
example page (client nav) dark: true
after reload dark at DOMContentLoaded: true now: true

# this branch, light system theme
examples index dark: false
example page (client nav) dark: false
after reload dark at DOMContentLoaded: false now: false

The new toggle on the example page switches to dark, and the saved choice beats a light system theme after a reload. The example header at 390 px fits with no page overflow (also checked at 783 and 1280):

example header with theme toggle at 390px

pnpm lint passes; LandingPage.test.tsx passes (22 tests).

Limits

  • Demo site only, so no changeset.
  • /folder keeps its own theme setting once a folder is open. Before a folder opens, the picker page now shows the site theme.

🤖 Generated with Claude Code

The theme was set only by the docs layout and site nav, and each put the
page root back to light when it unmounted. Example pages mount neither, so
opening one from /examples, or reloading it, showed the light theme.

index.html now sets the theme before the first paint on every page, the
theme hook no longer reverts the root, and the example header has its own
theme toggle.

Closes #672

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@byronwall
byronwall merged commit c59b605 into main Nov 22, 2026
2 checks passed
@byronwall
byronwall deleted the claude/fix-672-dark-mode-examples-698a0a branch November 22, 2026 03:10
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.

Website flash banged me when navigating from pleasant dark mode UI to opening specific example.

1 participant