Sthemer screenshot

Sthemer

Author Avatar Theme by Ivanhofer
Updated: 28 Jun 2023
27 Stars

A lightweight yet powerful solution to support multiple color schemes in your Svelte/SvelteKit application.

Categories

Overview

sthemer is a lightweight yet powerful solution for supporting multiple color schemes in Svelte and SvelteKit applications. It offers advantages such as being lightweight, powerful, easy to use, fast and efficient, and supporting both nested schemes and server-side rendering. It also has excellent TypeScript support, but also works with JavaScript projects.

Features

  • Lightweight (<1kb): sthemer is a lightweight solution, minimizing the impact on your application’s bundle size.
  • Powerful: sthemer provides robust functionality for managing multiple color schemes in your Svelte applications.
  • Easy to use: The setup process and usage of sthemer is straightforward, allowing developers to quickly implement and customize color schemes.
  • Fast and efficient: sthemer is designed to be performant, ensuring a smooth user experience.
  • Nested schemes: sthemer supports nested color schemes, allowing for greater flexibility in customization.
  • Supports SSR (Server-Side Rendering): sthemer is compatible with server-side rendering, ensuring consistent color schemes across different stages of rendering.
  • Best TypeScript support (works with JavaScript projects too): sthemer has excellent support for TypeScript, making it suitable for projects using either TypeScript or JavaScript.
  • No external dependencies: sthemer does not rely on any external dependencies, reducing potential compatibility issues.

Installation

To install sthemer as a dependency:

  1. Add sthemer to your project’s dependencies:
npm install sthemer
  1. Add the style mixin globally in your svelte.config.js file:
// svelte.config.js

import { mixins } from 'svelte-preprocess';

module.exports = {
  preprocess: [
    mixins([
      // Add the style mixin globally
      require('sthemer/mixins/style')()
    ])
  ]
};
  1. Wrap your code with the Sthemer.svelte component and define your preferred strategy:
<!-- App.svelte or __layout.svelte -->

<script>
  import { Sthemer } from 'sthemer';
</script>

<Sthemer strategy="auto">
  <!-- Define styles for your components -->
</Sthemer>
  1. That’s it! You can now explore the sthemer documentation and examples to further customize and implement color schemes.

Summary

sthemer is a lightweight and powerful solution for managing multiple color schemes in Svelte and SvelteKit applications. It offers easy installation and usage, with features such as support for nested schemes, server-side rendering, and excellent TypeScript support. With sthemer, developers can efficiently customize and implement color schemes to enhance the user experience of their applications.