diff --git a/.changeset/nice-cats-know.md b/.changeset/nice-cats-know.md new file mode 100644 index 000000000..4ed7f44e8 --- /dev/null +++ b/.changeset/nice-cats-know.md @@ -0,0 +1,5 @@ +--- +"svelte-ux": patch +--- + +Fix ThemeSwitch SSR behavior by using `dark` class to define positioning and icon display diff --git a/packages/svelte-ux/src/lib/components/ThemeSwitch.svelte b/packages/svelte-ux/src/lib/components/ThemeSwitch.svelte index 0361679ef..26e220476 100644 --- a/packages/svelte-ux/src/lib/components/ThemeSwitch.svelte +++ b/packages/svelte-ux/src/lib/components/ThemeSwitch.svelte @@ -15,12 +15,22 @@ let newTheme = e.target?.checked ? 'dark' : 'light'; currentTheme.setTheme(newTheme); }} - let:checked + classes={{ + switch: 'dark:bg-primary dark:border-primary', + toggle: 'translate-x-0 dark:translate-x-full', + }} {...$$restProps} > - {#if checked} - - {:else} - - {/if} +
+ + +