npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lineus/svelte-color-scheme

v0.1.2

Published

**_A library for managing light and dark mode for a sveltekit site._**

Readme

@lineus/svelte-color-scheme

A library for managing light and dark mode for a sveltekit site.

Summary

When you create a SchemeState instance ( provided in a svelte context ) that instance uses a svelte MediaQuery, the browser's localStorage, and svelte reactivity to track both the visitor's system scheme preference and their preference on your site to update the current scheme.

site has 3 options. light, dark, and system. light and dark take precedence over system which when selected is either light or dark based on your system setting

Expected Default Behavior

  1. First time visitors will get their system's current scheme.
  2. Setting the site state to 'light' or 'dark' will override their system preference.
  3. When the site state is set to 'system' the site will honor their system setting preference.
  4. Any change to either the site or system preference will cause the value of the SchemeState instance's .current property to update.

Options

  1. The behavior of defaulting to the system preference can be overriden.

createSchemeState({ default: 'dark' }) and using a custom svelte:head with a fn to prevent a Flash Of Unwanted Content that updates the classlist or dataset to dark will mean that your site defaults to dark mode but the user can override it to be light or follow their system.

  1. What happens when the SchemeState instance's .current property is updated is entirely up to you. Put it in an $effect or {} and your ui will change accordingly.

Installing

npm

npm install @lineus/svelte-color-scheme

pnpm

pnpm install @lineus/svelte-color-scheme

Provides

  1. createSchemeState() - a fn that creates the context and instantiates SchemeState.

  2. getSchemeState() - a fn that retrieves the SchemeState instance from the context.

  3. a <SchemeDatasetHeader /> - an optional component to add an iife to <svelte:head> on first load that will set a data attribute called scheme on the html element. This is to prevent a FOUC.

  4. a <SchemeClassHeader /> - an optional component to add an iiffe to <svelte:head> on first load that will add a dark class to the html element. This is to prevent a FOUC.

How to use svelte-color-scheme in your sveltekit project

in the script of +layout.svelte (presumably the root level):

  1. import the createSchemeState function
  2. call createSchemeState()
  3. import and add the SchemeDatasetHeader or SchemeClassHeader component or write your own logic to prevent FOUC and include it here. These components are merely provided as a convenience based on two strategies for implementing light/dark mode.

in a scheme selecting component of your own making:

  1. import the getSchemaState function
  2. call const scheme = getSchemeState()
  3. wire up the ui to the state (see examples)
  4. watch the scheme change in all open tabs :)

How to run the examples

  1. clone this repo to a folder on your system
  2. cd into the directory
  3. npm install or pnpm install
  4. npm run dev --open or pnpm run dev --open
  5. interact with the button and the slider to see the scheme change