From 1d5d745823aae7019044e8b0a621af4366dae224 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Wed, 3 Jun 2026 16:03:21 +0200 Subject: [PATCH] Make theme switcher three-way (auto/light/dark) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default is "auto", which inherits from the OS via prefers-color-scheme and follows it live. Clicking cycles auto → light → dark → auto; the explicit choice persists in localStorage while auto stores nothing. The toggle shows the active preference (half-circle / sun / moon) keyed on a new data-theme-pref attribute, so "auto" is its own visible state rather than collapsing into whatever the OS resolved to. Co-Authored-By: Claude Opus 4.8 (1M context) --- site/components/Header.astro | 9 ++-- site/layouts/Base.astro | 11 +++-- site/pages/design-system/index.astro | 9 ++-- site/scripts/utils/theme.js | 68 ++++++++++++++++++++++------ site/styles/light-mode.css | 37 +++++++++------ 5 files changed, 96 insertions(+), 38 deletions(-) diff --git a/site/components/Header.astro b/site/components/Header.astro index fc507bd39..6713eea50 100644 --- a/site/components/Header.astro +++ b/site/components/Header.astro @@ -38,10 +38,13 @@ const { activeNav } = Astro.props; type="button" class="theme-toggle" data-theme-toggle - aria-label="Switch to light mode" - title="Light mode" - data-next-theme="light" + aria-label="Theme: auto, matching your system. Click to switch to light mode." + title="Theme: auto (matches system)" > +