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

utility-css-library

v1.0.0

Published

Modern utility CSS library with intelligent theming, automatic contrast calculation, and seamless dark/light mode support

Downloads

12

Readme

🎨 Intelligent Theming System

A modern, production-ready utility CSS library with intelligent theming, automatic contrast calculation, and seamless dark/light mode support.

✨ Features

🎯 Intelligent Theming

  • Automatic Contrast Calculation: Colors automatically generate optimal text colors for maximum readability
  • Semantic Color System: 7 carefully chosen semantic colors with intelligent foreground text
  • Smart Hover States: Automatic color darkening for interactive elements
  • Opacity Variants: Pre-generated opacity levels (10%, 20%, 30%, 50%, 70%) for each color

🌙 Dark/Light Mode Support

  • System Preference Detection: Automatically respects user's OS theme preference
  • Runtime Theme Switching: Toggle between modes with smooth transitions
  • Persistent Theme State: Remembers user's theme preference across sessions
  • CSS Custom Properties: All colors adapt automatically in both modes

🎨 Color Palette

  • Primary (#6C5CE7) - Purple for primary actions
  • Doom (#2B2B2B) - Dark gray for sophisticated elements
  • White (#FFFFFF) - Pure white with smart borders
  • Critical (#E62E5C) - Red for errors and warnings
  • Warning (#E6E35C) - Yellow for attention (uses black text automatically)
  • Success (#37B26C) - Green for positive actions
  • Interactive (#0984E3) - Blue for links and interactive elements

🏗️ TypeScript Architecture

  • Type-Safe Design Tokens: Complete TypeScript interfaces for all tokens
  • ThemeManager Class: Runtime theme management with event subscriptions
  • TokenManager Class: CSS custom property generation and management
  • Contrast Algorithms: Scientific luminance and contrast ratio calculations

🚀 Quick Start

Installation

npm install @organization/design-system

Basic Usage

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="node_modules/@organization/design-system/dist/main.css">
</head>
<body>
    <!-- Semantic color buttons with automatic contrast -->
    <button class="btn btn-primary">Primary Action</button>
    <button class="btn btn-warning">Warning (Black Text)</button>
    <button class="btn btn-success">Success Action</button>
    
    <!-- Theme toggle -->
    <button onclick="toggleMode()">Toggle Dark/Light</button>
    
    <script src="node_modules/@organization/design-system/dist/main.js"></script>
    <script>
        function toggleMode() {
            if (window.themeManager) {
                window.themeManager.toggleMode();
            }
        }
    </script>
</body>
</html>

TypeScript Usage

import { ThemeManager, TokenManager, DesignTokens } from '@organization/design-system';

// Initialize theme management
const themeManager = new ThemeManager();
const tokenManager = new TokenManager();

// Toggle theme programmatically
themeManager.toggleMode();

// Get current theme
const currentMode = themeManager.getCurrentMode(); // 'light' | 'dark'

// Subscribe to theme changes
themeManager.subscribe((mode) => {
    console.log(`Theme changed to: ${mode}`);
});

// Access design tokens
const primaryColor = DesignTokens.colors.primary.value; // #6C5CE7
const primaryForeground = DesignTokens.colors.primary.foreground; // #ffffff

🎨 Color System

Semantic Colors with Automatic Contrast

Each color automatically calculates the optimal foreground text color:

/* Yellow warning uses black text for readability */
.btn-warning {
    background-color: var(--color-warning, #E6E35C);
    color: var(--color-warning-foreground, #000000); /* Automatically black */
}

/* Dark colors use white text */
.btn-doom {
    background-color: var(--color-doom, #2B2B2B);
    color: var(--color-doom-foreground, #ffffff); /* Automatically white */
}

Opacity Variants

/* Available for all semantic colors */
.bg-primary-10 { background-color: var(--color-primary-10); } /* 10% opacity */
.bg-primary-20 { background-color: var(--color-primary-20); } /* 20% opacity */
.bg-primary-30 { background-color: var(--color-primary-30); } /* 30% opacity */
.bg-primary-50 { background-color: var(--color-primary-50); } /* 50% opacity */
.bg-primary-70 { background-color: var(--color-primary-70); } /* 70% opacity */

🌙 Dark Mode

Automatic Theme Detection

// Theme manager automatically detects system preference
const themeManager = new ThemeManager();
// Respects prefers-color-scheme: dark

Manual Theme Control

/* Light mode (default) */
:root {
    --color-background: #ffffff;
    --color-foreground: #09090b;
}

/* Dark mode */
:root.dark,
[data-mode="dark"] {
    --color-background: #09090b;
    --color-foreground: #fafafa;
}

🎯 Available Utility Classes

Color Classes

/* Background colors */
.bg-primary, .bg-doom, .bg-white, .bg-critical, .bg-warning, .bg-success, .bg-interactive

/* Text colors */
.text-primary, .text-doom, .text-white, .text-critical, .text-warning, .text-success, .text-interactive

/* Button styles */
.btn-primary, .btn-doom, .btn-white, .btn-critical, .btn-warning, .btn-success, .btn-interactive

Typography

/* Font sizes */
.text-xs, .text-sm, .text-base, .text-lg, .text-xl, .text-2xl, .text-3xl

/* Font weights */
.font-light, .font-normal, .font-medium, .font-semibold, .font-bold

Layout & Spacing

/* Spacing utilities */
.m-1, .m-2, .m-4, .p-1, .p-2, .p-4 /* etc. */

/* Flexbox */
.flex, .flex-col, .justify-center, .items-center /* etc. */

/* Grid */
.grid, .grid-cols-1, .grid-cols-2, .grid-cols-3 /* etc. */

🔧 Development

Build the Project

npm run build        # Production build
npm run build:dev    # Development build
npm run dev          # Development server
npm run watch        # Watch mode

Project Structure

src/
├── styles/           # SCSS utility classes
│   ├── abstracts/   # Variables and mixins
│   ├── base/        # Reset and base styles
│   └── utilities/   # Utility classes
├── tokens/          # Design token system
│   ├── design-tokens.ts    # Token definitions
│   ├── theme-manager.ts    # Theme management
│   └── token-manager.ts    # Token utilities
├── types/           # TypeScript type definitions
└── utils/           # Utility functions

📊 Performance

  • Bundle Size: ~240KB (CSS + JS)
  • Dependencies: Minimal, only build tools
  • Browser Support: Modern browsers (ES2020+)
  • Theme Switch: < 16ms transition time

🎨 Demo

Visit the live demo to see all features in action:

  • Interactive color demonstrations
  • Real-time theme switching
  • Typography system showcase
  • Responsive design examples

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Inspired by Tailwind CSS utility-first approach
  • Color contrast algorithms based on WCAG guidelines
  • Theme management patterns from modern design systems

Built with ❤️ for accessible, intelligent design systems.