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

tw-theme-kit

v1.1.0

Published

Professional Tailwind CSS plugin for multi-theme color systems with one className

Readme

tw-theme-kit

Switch Tailwind color themes with one class. Built for Tailwind CSS v4.

Version: 1.1.0


Install

npm i -D tw-theme-kit

Tailwind CSS v4 is required. npm installs it automatically as a peer dependency.


Setup

1. Add the plugintailwind.config.js

import { createThemes } from 'tw-theme-kit';

export default {
  content: ['./src/**/*.{html,js,jsx,ts,tsx,vue,svelte,astro}'],
  plugins: [
    createThemes({
      light: {
        primary: 'steelblue',
        secondary: 'darkblue',
        brand: '#F3F3F3',
      },
      dark: {
        primary: 'turquoise',
        secondary: 'tomato',
        brand: '#4A4A4A',
      },
    }),
  ],
};

CommonJS:

const { createThemes } = require('tw-theme-kit');

2. Link the config — your CSS entry file

@import "tailwindcss";
@config "./tailwind.config.js";

3. Apply a theme — add the theme name as a class

<html class="light">
  <div class="bg-brand">
    <h1 class="text-primary">Hello</h1>
    <p class="text-secondary">World</p>
  </div>
</html>

Switch themes by changing the class: <html class="dark">


Features

| Feature | Description | | --- | --- | | One-class switching | Apply light, dark, or any custom theme name as a class | | OKLCH colors | Automatic conversion for Tailwind v4 opacity support | | Theme variants | Use dark:rounded to style elements per active theme | | Nested themes | Scope themes to subtrees with data-theme | | Nested palettes | { DEFAULT, 100, 200 } objects flatten to primary, primary-100, etc. | | CSS variables | --ttk-primary, --ttk-secondary, … available in custom CSS | | ESM + CJS | Works with import and require | | TypeScript | Full type declarations included |


API

import {
  createThemes,
  resolveThemeKitConfig,
  generateVariantDefinitions,
  isThemeKitColorError,
  isThemeKitError,
  themeKitMeta,
  ThemeKitColorError,
  ThemeKitError,
} from 'tw-theme-kit';

createThemes(config, options?) — returns a Tailwind plugin.

resolveThemeKitConfig(config, options?) — returns { variants, utilities, colors } without wrapping in a plugin. Useful for custom tooling.

generateVariantDefinitions(selector) — returns nested-theme-aware Tailwind variant selectors for a theme class.

isThemeKitError(value) / isThemeKitColorError(value) — runtime type guards for error handling.

themeKitMeta — frozen { name, version, cssVariablePrefix } for logging and tooling.

Lightweight runtime entry — import primitives only (no Tailwind plugin):

import { themeKitMeta, generateVariantDefinitions } from 'tw-theme-kit/runtime';

Types: ThemeKitConfig, ThemeKitOptions


Examples

Multiple themes

createThemes({
  light: { primary: 'steelblue', brand: '#F3F3F3' },
  dark:  { primary: 'turquoise', brand: '#4A4A4A' },
  forest: { primary: '#2A9D8F', brand: '#264653' },
});

Nested color scales

createThemes({
  light: {
    primary: {
      DEFAULT: 'orange',
      100: 'red',
      200: 'blue',
    },
  },
});
// → bg-primary, bg-primary-100, bg-primary-200

Color-scheme helpers

createThemes(({ light, dark }) => ({
  winter: light({ primary: 'white', surface: '#F3F3F3' }),
  forest: dark({ primary: 'black', surface: '#1A1A1A' }),
}));

CSS variables

.card {
  color: var(--ttk-primary);
  background: var(--ttk-brand);
}

Theme variants

<button class="dark:bg-white dark:text-black">Themed button</button>

Nested themes

<html class="dark">
  <div data-theme class="winter">
    <!-- winter colors apply here -->
  </div>
</html>

Place group-* modifiers before theme variants: group-hover:dark:bg-red-500


Options

createThemes(config, {
  produceCssVariable: (name) => `--ttk-${name}`,   // default
  produceThemeClass:  (name) => name,               // default
  produceThemeVariant: (name) => name,             // default, same as produceThemeClass
  strict: false,                                    // throw ThemeKitColorError on bad colors
});

| Option | Default | Purpose | | --- | --- | --- | | produceCssVariable | `--ttk-${name}` | CSS custom property name | | produceThemeClass | theme name | Class applied to activate a theme | | produceThemeVariant | same as class | Prefix for variant utilities | | strict | false | Fail on invalid color values |


License

MIT