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

@solidcn/themes

v0.0.2

Published

Theming, design tokens, and ThemeProvider for solidcn

Readme

@solidcn/themes

Theme management for SolidJS applications with CSS custom properties, runtime provider, and built-in design token system.

Installation

npm install @solidcn/themes

Requires solid-js ≥ 1.9.

Features

  • CSS variable tokens — design tokens expressed as semantic names (background, foreground, primary, etc.)
  • ThemeProvider — declarative context provider with automatic .dark class management
  • 7 built-in themesdefault, slate, zinc, rose, blue, green, orange
  • Runtime theme switching — change palettes without page reload
  • Persistence — color scheme preference stored in localStorage
  • System detection — respects prefers-color-scheme by default
  • Token utilities — convert theme objects to CSS strings or inline style maps

Quick Start

Wrap your app with the provider:

import { ThemeProvider } from "@solidcn/themes/provider";

export default function App() {
  return (
    <ThemeProvider>
      <Router />
    </ThemeProvider>
  );
}

Or with explicit configuration:

import { ThemeProvider } from "@solidcn/themes/provider";

<ThemeProvider
  theme="zinc"
  colorScheme="system"
  darkModeStrategy="class"
  scope="root"
>
  <Router />
</ThemeProvider>;

ThemeProvider API

interface ThemeProviderProps {
  theme?: BuiltInTheme | ThemeDefinition;
  colorScheme?: "light" | "dark" | "system";
  darkModeStrategy?: "class" | "media";
  scope?: "root" | "self";
  storageKey?: string | null;
  children: JSX.Element;
}

| Prop | Type | Default | Description | |---|---|---|---| | theme | BuiltInTheme \| ThemeDefinition | "default" | Initial theme palette | | colorScheme | "light" \| "dark" \| "system" | "system" | Preferred color scheme | | darkModeStrategy | "class" \| "media" | "class" | How to activate dark mode. "class" toggles .dark on <html>, "media" uses prefers-color-scheme | | scope | "root" \| "self" | "root" | Where CSS variables are injected. "root" injects into document.documentElement, "self" applies inline on the provider wrapper | | storageKey | string \| null | "solidcn-color-scheme" | localStorage key for persisting color scheme. Set to null to disable persistence |

useTheme

Access the current theme context from any descendant component:

import { useTheme } from "@solidcn/themes/provider";

function ThemeSwitcher() {
  const themeCtx = useTheme();

  return (
    <button onClick={() => themeCtx.setColorScheme("dark")}>
      Dark mode
    </button>
  );
}

Returns ThemeContextValue:

interface ThemeContextValue {
  theme: () => ThemeDefinition;
  colorScheme: () => "light" | "dark" | "system";
  isDark: () => boolean;
  setTheme: (theme: BuiltInTheme | ThemeDefinition) => void;
  setColorScheme: (scheme: "light" | "dark" | "system") => void;
}

useColorScheme

Convenience hook with additional controls:

import { useColorScheme } from "@solidcn/themes/provider";

function ColorSchemeToggle() {
  const { colorScheme, isDark, toggle, cycle, setColorScheme } = useColorScheme();

  return (
    <button onClick={toggle}>
      {isDark() ? "Light" : "Dark"}
    </button>
  );
}

Returns:

interface UseColorSchemeReturn {
  colorScheme: () => "light" | "dark" | "system";
  isDark: () => boolean;
  toggle: () => void;
  cycle: () => void;
  setColorScheme: (scheme: "light" | "dark" | "system") => void;
}

Built-in Themes

Available through the presets export:

import {
  builtInThemes,
  defaultTheme,
  slateTheme,
  zincTheme,
  roseTheme,
  blueTheme,
  greenTheme,
  orangeTheme,
  getTheme,
} from "@solidcn/themes/presets";

Each theme implements the ThemeDefinition interface with light and dark color palettes.

Custom Themes

Define your own theme by implementing ThemeDefinition:

import type { ThemeDefinition } from "@solidcn/themes/tokens";

const myTheme: ThemeDefinition = {
  name: "my-theme",
  label: "My Theme",
  light: {
    background: "0 0% 100%",
    foreground: "222.2 84% 4.9%",
    primary: "221.2 83% 53.3%",
    // ...
  },
  dark: {
    background: "222.2 84% 4.9%",
    foreground: "210 40% 98%",
    primary: "217.2 91.2% 59.8%",
    // ...
  },
};

Token Utilities

toCssVar

Convert a token name and value to a CSS variable declaration:

import { toCssVar } from "@solidcn/themes/tokens";

toCssVar("background", "0 0% 100%");
// "--background: 0 0% 100%"

themeToCSS

Generate a complete CSS string with :root and .dark blocks:

import { themeToCSS } from "@solidcn/themes/tokens";

const css = themeToCSS(zincTheme);
// ":root { --background: ...; ... }\n\n.dark { --background: ...; ... }"

themeToStyle

Generate a style object for inline injection:

import { themeToStyle } from "@solidcn/themes/tokens";

const style = themeToStyle(zincTheme.light);
// { "--background": "...", "--foreground": "...", ... }

Token Names

The following semantic token names are supported:

| Token | Description | |---|---| | background | Page background | | foreground | Primary text color | | card | Card background | | card-foreground | Card text color | | primary | Primary action color | | primary-foreground | Primary action text color | | secondary | Secondary surface color | | secondary-foreground | Secondary surface text color | | destructive | Danger/destructive color | | destructive-foreground | Danger text color | | muted | Muted/subtle background | | muted-foreground | Muted text color | | accent | Accent highlight color | | accent-foreground | Accent text color | | border | Border color | | input | Input border color | | ring | Focus ring color | | radius | Border radius | | sidebar-* | Sidebar-specific tokens | | chart-* | Chart color tokens |

License

MIT