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

tailwind-color-theme-plugin

v2.0.0

Published

A reusable Vite plugin for Tailwind 4 theming with dynamic color configuration

Readme

A reusable Vite plugin for Tailwind CSS 4 theming with dynamic color configuration. Inspired by Nuxt UI's theming system and made framework-agnostic.

Live Demo - See the plugin in action with interactive theme switching!

Features

  • Dynamic color theming with CSS variables
  • Built-in dark/light mode support with adaptive shade shifting
  • Semantic color utilities (text-default, bg-muted, border-accented)
  • Custom CSS variables injection
  • Framework agnostic (works with Vue, React, Svelte, etc.)
  • Powered by Vite and Unplugin
  • TypeScript support
  • User @theme override detection

Installation

npm install tailwind-color-theme-plugin

Basic Setup

// vite.config.ts
import { defineConfig } from 'vite'
import tailwindTheme from 'tailwind-color-theme-plugin'

export default defineConfig({
  plugins: [
    tailwindTheme({
      colors: {
        primary: 'sky',
        secondary: 'purple',
        success: 'green',
        warning: 'orange',
        error: 'red',
        neutral: 'gray'
      }
    })
  ]
})

CSS Setup

Import Tailwind and the theme CSS:

/* src/style.css */
@import "tailwindcss";
@import "tailwind-color-theme-plugin/theme.css";

Override colors using Tailwind 4's @theme syntax:

@theme static {
  --color-green-500: #00FFFF;
  --color-green-600: #00E6E6;
}

Configuration Options

export interface TailwindThemeOptions {
  colors?: Record<string, Color> & { 
    primary?: Color
    secondary?: Color
    success?: Color
    info?: Color
    warning?: Color
    error?: Color
    neutral?: Color 
  }
  customVariables?: Record<string, string>
  injectColors?: boolean
  prefix?: string
  extendTailwindTheme?: boolean
  includeSemanticColors?: boolean
  adaptiveShades?: boolean
}

Configuration Options

  • colors - Theme color configuration using Tailwind color names
  • customVariables - Additional CSS variables to inject
  • injectColors - Whether to inject colors via JavaScript (default: true)
  • prefix - CSS variable prefix (default: 'ui')
  • extendTailwindTheme - Enable Tailwind theme extension (default: true)
  • includeSemanticColors - Include semantic utilities (default: true)
  • adaptiveShades - Enable adaptive shade shifting in dark mode (default: true)

Using Theme Colors

Tailwind Utilities

<!-- Theme colors with shades -->
<button class="bg-primary-500 text-white">Primary Button</button>
<div class="text-secondary-600 border-success-300">Colored content</div>

<!-- Adaptive colors (automatically shift shades in dark mode) -->
<button class="bg-primary text-inverted">Adaptive Button</button>
<div class="text-secondary border-success">Adaptive content</div>

<!-- Semantic utilities -->
<p class="text-default">Default text</p>
<p class="text-muted">Muted text</p>
<div class="bg-elevated border-default">Elevated card</div>
<div class="bg-muted border-accented">Muted card</div>

Generated CSS Variables

/* Theme colors */
--ui-primary: /* adaptive primary color */
--ui-secondary: /* adaptive secondary color */
--ui-color-primary-500: /* primary 500 shade */

/* Semantic colors */
--ui-text: /* default text color */
--ui-text-muted: /* muted text color */
--ui-bg: /* default background */
--ui-bg-elevated: /* elevated background */
--ui-border: /* default border color */

Dark Mode & Adaptive Shades

The plugin automatically handles dark mode with adaptive shade shifting:

  • Light mode: Primary uses shade 500
  • Dark mode: Primary uses shade 400 (lighter for better contrast)

Toggle dark mode:

document.documentElement.classList.toggle('dark')

Disable adaptive shades:

tailwindTheme({
  adaptiveShades: false // Use same shade in both light and dark mode
})

Semantic Color System

Framework-agnostic semantic utilities:

Text Colors

  • text-default - Primary text
  • text-muted - Secondary text
  • text-toned - Subtle text
  • text-dimmed - Disabled text
  • text-highlighted - Emphasized text
  • text-inverted - Inverted text

Background Colors

  • bg-default - Default background
  • bg-muted - Muted background
  • bg-elevated - Elevated/card background
  • bg-accented - Accented background
  • bg-inverted - Inverted background

Border Colors

  • border-default - Default border
  • border-muted - Muted border
  • border-accented - Accented border
  • border-inverted - Inverted border

Custom Variables

Inject additional CSS variables:

tailwindTheme({
  customVariables: {
    'border-radius': '0.5rem',
    'font-family': '"Inter", sans-serif',
    'spacing-unit': '4px'
  }
})

Available as --ui-border-radius, --ui-font-family, etc.

User Theme Overrides

The plugin automatically detects user @theme overrides and excludes those colors from generation:

@theme static {
  --color-green-500: #00FFFF;
  --color-green-600: #00E6E6;
}

Example Project

Check out the example/ directory for a complete implementation showing:

  • Color palette showcase
  • Semantic design system demonstration
  • Dark mode functionality
  • Dynamic theme switching with ThemePicker component
  • Tailwind 4 @theme syntax usage

The example includes a ThemePicker component that demonstrates how to build dynamic color switching functionality.

Framework Integration

Vue.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindTheme from 'tailwind-color-theme-plugin'

export default defineConfig({
  plugins: [vue(), tailwindTheme()]
})

React

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindTheme from 'tailwind-color-theme-plugin'

export default defineConfig({
  plugins: [react(), tailwindTheme()]
})

Svelte

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import tailwindTheme from 'tailwind-color-theme-plugin'

export default defineConfig({
  plugins: [svelte(), tailwindTheme()]
})

Requirements

  • Vite 6.0+ or 7.0+
  • Tailwind CSS 4.0+
  • Node.js 18+

Special Thanks to

  • Nuxt UI: For the Main Inspiration for this plugin and their incredible Theming System

License

MIT