Skip to content

site: Simplify the colour mode toggle - #1806

Closed
askoufis wants to merge 1 commit into
astro/docs-mdxfrom
astro/color-mode
Closed

askoufis wants to merge 1 commit into
astro/docs-mdxfrom
astro/color-mode

Conversation

@askoufis

@askoufis askoufis commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

The colour mode toggle kept the current mode in React context, but the source of truth is already the class on the html element, set by the inline script in the document head before the page renders. This removes the context and reads the class instead.

  • Moves lightMode, darkMode and the localStorage key into system/styles/colorModes.ts. They can then be imported without pulling in the sprinkles CSS, e.g. from the document head. sprinkles.css.ts re-exports the modes, so existing imports keep working.
  • ColorModeToggle toggles the class on html and saves the preference, with no state of its own.
  • Removes ColorModeProvider.

This also means each toggle can be its own component tree, which the Astro migration relies on.


Stack created with GitHub Stacks CLI • Give Feedback 💬

The colour mode toggle kept the current mode in React context, but the source of truth is already the class on the `html` element, set by the inline script in the document head before the page renders. This removes the context and reads the class instead.

- Moves `lightMode`, `darkMode` and the `localStorage` key into `system/styles/colorModes.ts`. They can then be imported without pulling in the sprinkles CSS, e.g. from the document head. `sprinkles.css.ts` re-exports the modes, so existing imports keep working.
- `ColorModeToggle` toggles the class on `html` and saves the preference, with no state of its own.
- Removes `ColorModeProvider`.

This also means each toggle can be its own component tree, which the Astro migration relies on.
@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 73d7693

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@askoufis
askoufis added this pull request to stack #1804 November 4, 2026 11:29
@askoufis askoufis closed this Nov 8, 2026
@askoufis
askoufis deleted the astro/color-mode branch November 8, 2026 10:36
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.

1 participant