Download web/src/lib/ThemeToggle.svelte from reversely/lifekit: direct link, hf CLI and curl.
- Browser
- Download file 538 Bytes
-
https://huggingface.co/spaces/reversely/lifekit/resolve/main/web/src/lib/ThemeToggle.svelte
- Command line
-
hf download hf://spaces/reversely/lifekit/web/src/lib/ThemeToggle.svelte
-
curl -L -o ThemeToggle.svelte https://huggingface.co/spaces/reversely/lifekit/resolve/main/web/src/lib/ThemeToggle.svelte
538 Bytes
| <script lang="ts"> | |
| // Light or dark: a button with the sun icon in dark mode and the moon in light mode. | |
| import Icon from './Icon.svelte'; | |
| import { theme, toggleTheme } from './core/theme'; | |
| export let size = 16; | |
| export let iconOnly = false; | |
| $: label = $theme === 'dark' ? 'Light mode' : 'Dark mode'; | |
| </script> | |
| <button class="mode" class:icon-only={iconOnly} aria-label={label} title={label} on:click={toggleTheme}> | |
| <Icon name={$theme === 'dark' ? 'sun' : 'moon'} {size} />{#if !iconOnly}<span>{label}</span>{/if} | |
| </button> | |