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

solid-theme-provider

v1.1.1

Published

Lightweight and customizable theme handler for Solid JS

Readme

solid-theme-provider

npm version npm downloads bundle size license

A SolidJS theme provider that injects CSS variables into :root on theme switch, with built-in UI components and automatic system preference detection.

Live Demo →

Installation

npm install solid-theme-provider

Quick Start

Wrap your app in ThemeProvider and place ThemeToggle or ThemePicker anywhere inside it. No configuration required — it detects system light/dark preference automatically.

import { ThemeProvider, ThemeToggle } from "solid-theme-provider";

export default function App() {
  return (
    <ThemeProvider>
      <nav>
        <ThemeToggle label="Toggle Theme" />
      </nav>
    </ThemeProvider>
  );
}

UI Components

ThemeToggle

Toggles between the defined default light and dark themes.

| Prop | Type | Default | | --- | --- | --- | | label | string | — | | classList | Record<string, boolean> | — |

ThemePicker

Opens a dropdown listing all available themes as well as a "Match System" setting.

| Prop | Type | Default | | --- | --- | --- | | label | string | "Theme" | | menuPlacement | "ne" \| "se" \| "sw" \| "nw" | "se" | | classList | Record<string, boolean> | — |

ThemeProvider Props

| Prop | Type | Default | | --- | --- | --- | | themes | ThemesConfig | built-in light/dark | | default | string | system preference | | prefix | string | "stp-" | | calculateVariants | (name, value) => ThemeVars | hex alpha variants |

CSS Variables

On every theme switch, all variables defined in your theme's vars object are injected into :root. The built-in themes define these defaults:

--stp-background
--stp-foreground
--stp-button-radius

In practice you'll define your own variables — any key/value pair in vars becomes a CSS custom property. Your stylesheets then consume them directly:

body, html {
  background: var(--stp-background);
  color: var(--stp-foreground);
}

Alpha Variants

Any hex color variable automatically generates four transparent variants:

| Suffix | Opacity | | --- | --- | | -alpha-primary | 95% | | -alpha-secondary | 60% | | -alpha-tertiary | 30% | | -alpha-quaternary | 9% |

For example, --stp-foreground generates --stp-foreground-alpha-quaternary, useful for subtle hover states and borders.

Custom Themes

import { ThemeProvider, ThemePicker } from "solid-theme-provider";
import type { ThemesConfig } from "solid-theme-provider";

const themes: ThemesConfig = {
  systemThemes: { dark: "ember_night", light: "warm_light" },
  themes: {
    ember_night: {
      config: { browserThemeColor: "#110000" },
      vars: { background: "#110000", foreground: "#ddddcc", button-radius: "0.5em" },
    },
    warm_light: {
      config: { browserThemeColor: "#f1efe5" },
      vars: { background: "#fffff5", foreground: "#111100", button-radius: "0.5em" },
    },
  },
};

<ThemeProvider themes={themes}>
  <ThemePicker />
</ThemeProvider>

Note: Only one ThemeProvider should exist in your app. The snippet above is illustrative — in practice, themes is passed to the one and only provider you should have, the provider that wraps your app.

systemThemes maps which of your themes should be applied when following system light/dark preference. See the Custom Themes demo for a full example.

Theme Config Options

Each theme can include an optional config object:

| Field | Type | Description | | --- | --- | --- | | label | string | Display name in the picker (defaults to title-cased key) | | icon | () => JSX.Element | Icon shown in the picker | | browserThemeColor | string | Sets <meta name="theme-color"> | | colorScheme | "light" \| "dark" | Sets color-scheme on <html> so native UI (scrollbars, form controls) match the theme. Inferred automatically for themes mapped in systemThemes. |

Advanced Usage

useTheme() exposes the full context for driving theme state from your own code:

import { useTheme } from "solid-theme-provider";

function MyComponent() {
  const { currentTheme, setTheme, themes } = useTheme();

  return <div>Current theme: {currentTheme()}</div>;
}

See the Advanced demo for more examples including setThemesConfig for runtime theme config updates.

Image Inversion

The provider injects styles that automatically invert images when the opposing system theme is active. See the Image Invert demo for full usage details.

<!-- Invert when dark theme is active -->
<img class="invert-safe--light" src="..." />

<!-- Invert when light theme is active -->
<img class="invert-safe--dark" src="..." />

<!-- Also works via URL fragment -->
<img src="./logo.png#invert-safe--light" />