svelte-themer
- Purpose: A theming engine for Svelte apps using CSS Variables, with persistence support.
- Key Features:
- Generates CSS variables for themes using a structured nomenclature (e.g.,
--theme-text
,--base-text
). - Supports nested theme properties (e.g.,
--theme-light-colors-background
). - Provides preset themes and allows custom theme creation.
- Persists theme choices via
localStorage
. - Automatically loads themes based on user preference, OS settings, or a fallback.
- Generates CSS variables for themes using a structured nomenclature (e.g.,
- Components:
ThemeWrapper
: Manages theme context and persistence.ThemeToggle
: A convenience button for switching themes.
- Target Audience: Svelte developers looking for a flexible and persistent theming solution.
- Framework Support: Primarily for Svelte, with no mention of other frameworks.
- Advanced Usage:
- Custom toggle buttons can be created using the exposed
toggle
function from the theme context. - Actions like
use:theme
anduse:stylesheet
for applying themes to specific elements.
- Custom toggle buttons can be created using the exposed
- Theme Loading Order:
- User-provided theme.
- Saved theme (from
localStorage
). - OS preference (
prefers-color-scheme
). - Fallback (first theme in the list).
For more details, check the [GitHub repository](https://github.com/svelte-themer#readme fa-solid fa-up-right-from-square).
themecss-variablessveltetheming
Author
Featured Stories
No featured articles here. Navigate to an article, then pick the Feature on menu button