svelte-dark-theme

☯ Dark Theme Manager for SvelteKit

Device
'light'
$setting
'sync'
$theme
'light'
<!-- +layout.svelte -->
<script>
  import { ThemeManager } from '@jill64/svelte-dark-theme'
</script>

<ThemeManager />
<script>
  import { theme } from '@jill64/svelte-dark-theme'

  // current theme light
  console.log(theme.value)

  // current theme is dark: false
  console.log(theme.isDark)

  // current theme is light: true
  console.log(theme.isLight)

  // current setting is 'sync'
  console.log(setting.see)

  const change_to_dark = () => {
    $theme = 'dark'
  }
</script>
// hooks.server.js
import { onRender } from '@jill64/svelte-dark-theme'
export const handle = onRender()