General

ThemeModeButton

A button that toggles between light and dark mode. Automatically manages theme state via mode-watcher with customizable icons and styling.

Playground

Basic Usage

Drop in anywhere. Works out of the box with mode-watcher.

<script lang="ts">
  import { ThemeModeButton } from 'sv5ui';
</script>

<ThemeModeButton />

Variants

ghost
outline
soft
subtle
solid
<ThemeModeButton variant="ghost" />
<ThemeModeButton variant="outline" />
<ThemeModeButton variant="soft" />
<ThemeModeButton variant="subtle" />
<ThemeModeButton variant="solid" />

Sizes

xs
sm
md
lg
xl
<ThemeModeButton size="xs" />
<ThemeModeButton size="sm" />
<ThemeModeButton size="md" />
<ThemeModeButton size="lg" />
<ThemeModeButton size="xl" />

Colors

<ThemeModeButton color="surface" />
<ThemeModeButton color="primary" />
<ThemeModeButton color="secondary" />
<ThemeModeButton color="success" />
<ThemeModeButton color="warning" />
<ThemeModeButton color="error" />
<ThemeModeButton color="info" />

Custom Icons

Override the default sun/moon icons.

<!-- Custom icon set -->
<ThemeModeButton
  lightIcon="lucide:sunrise"
  darkIcon="lucide:sunset"
/>

<!-- Different icon collections -->
<ThemeModeButton
  lightIcon="mdi:white-balance-sunny"
  darkIcon="mdi:weather-night"
/>

Custom Content

Use children snippet with isDark for fully custom content.

<ThemeModeButton>
  {#snippet children({ isDark })}
    {isDark ? '🌙' : '☀️'}
  {/snippet}
</ThemeModeButton>

Styled Examples

Navbar
Accent
Minimal
<!-- Outline style for navbars -->
<ThemeModeButton variant="outline" color="surface" />

<!-- Solid accent button -->
<ThemeModeButton variant="solid" color="primary" />

<!-- Subtle minimal style -->
<ThemeModeButton variant="subtle" color="surface" size="sm" />

UI Slots

SlotDescription
baseRoot button element — controls layout, colors, transitions
iconIcon element — controls icon sizing and shrink behavior

Snippets

SnippetPropsDescription
childrenisDark: booleanCustom content replacing default icon, receives current theme state

Props

PropTypeDefault
variant'solid'|'outline'|'soft'|'subtle'|'ghost'|'link''ghost'
colorColorType'surface'
size'xs'|'sm'|'md'|'lg'|'xl''md'
lightIconstring'lucide:sun'
darkIconstring'lucide:moon'
loadingbooleanfalse
disabledbooleanfalse
squarebooleantrue
blockbooleanfalse
classstring-
uiRecord<Slot, Class>-