From 62dc8398f691ce90d7b7fe0e13d446fcb3b0474b Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 16 Jul 2026 20:16:52 +0800 Subject: [PATCH] chore(example): set `color-cheme` This allows the unstyled user agent elements match the selected theme colors --- examples/api/index.html | 3 ++- examples/api/src/App.svelte | 12 ++++++++---- examples/api/src/app.css | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/examples/api/index.html b/examples/api/index.html index 5490c5c8e345..98132dfd03c5 100644 --- a/examples/api/index.html +++ b/examples/api/index.html @@ -1,8 +1,9 @@ - + + API Example App diff --git a/examples/api/src/App.svelte b/examples/api/src/App.svelte index 77097b7ef351..db719567d00f 100644 --- a/examples/api/src/App.svelte +++ b/examples/api/src/App.svelte @@ -102,9 +102,13 @@ function applyTheme() { const isDark = theme === 'auto' ? preferDark.current : theme === 'dark' - isDark - ? document.documentElement.classList.add('dark') - : document.documentElement.classList.remove('dark') + if (isDark) { + document.documentElement.classList.add('dark') + document.documentElement.classList.remove('light') + } else { + document.documentElement.classList.remove('dark') + document.documentElement.classList.add('light') + } setTheme(theme === 'auto' ? null : theme) localStorage.setItem('theme', theme) } @@ -240,7 +244,7 @@ id="sidebarToggle" bind:this={sidebarToggle} class="z-2000 hidden lt-sm:flex justify-center absolute items-center w-8 h-8 rd-8 - bg-accent dark:bg-darkAccent active:bg-accentDark dark:active:bg-darkAccentDark" + bg-accent dark:bg-darkAccent active:bg-accentDark dark:active:bg-darkAccentDark text-accentText dark:text-darkAccentText" > {#if isSideBarOpen} diff --git a/examples/api/src/app.css b/examples/api/src/app.css index f2be7ea1443c..fb91eca885ba 100644 --- a/examples/api/src/app.css +++ b/examples/api/src/app.css @@ -2,6 +2,13 @@ line-height: 1.5; } +:root.dark { + color-scheme: dark; +} +:root.light { + color-scheme: light; +} + input, select { min-width: 0;