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
| Slot | Description |
|---|---|
base | Root button element — controls layout, colors, transitions |
icon | Icon element — controls icon sizing and shrink behavior |
Snippets
| Snippet | Props | Description |
|---|---|---|
children | isDark: boolean | Custom content replacing default icon, receives current theme state |
Props
| Prop | Type | Default |
|---|---|---|
variant | 'solid'|'outline'|'soft'|'subtle'|'ghost'|'link' | 'ghost' |
color | ColorType | 'surface' |
size | 'xs'|'sm'|'md'|'lg'|'xl' | 'md' |
lightIcon | string | 'lucide:sun' |
darkIcon | string | 'lucide:moon' |
loading | boolean | false |
disabled | boolean | false |
square | boolean | true |
block | boolean | false |
class | string | - |
ui | Record<Slot, Class> | - |