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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@buildy-ui/theme

v1.0.1

Published

React theme state management library for utility and semantic CSS approaches

Downloads

14

Readme

@buildy-ui/theme

React theme state management library for utility and semantic CSS approaches.

Features

  • 🎨 Theme State Management - Switch between semantic and ui8kit themes
  • 💾 Persistent State - Theme preferences saved to localStorage
  • 🔄 URL Parameters - Theme switching via URL parameters
  • 🎯 TypeScript Support - Full type safety
  • 📦 ESM Ready - Modern ES modules
  • ⚛️ React Integration - Context API and hooks
  • 🚀 SSR Support - Server-side rendering compatible

Installation

npm install @buildy-ui/theme

Quick Start

1. Wrap Your App

import { ThemeProvider } from '@buildy-ui/theme';

function App() {
  return (
    <ThemeProvider>
      <YourApp />
    </ThemeProvider>
  );
}

2. Use Theme State

import { useTheme } from '@buildy-ui/theme';

function ThemeToggle() {
  const { current, setTheme, toggleTheme } = useTheme();
  
  return (
    <div>
      <p>Current theme: {current}</p>
      <button onClick={toggleTheme}>
        Switch to {current === 'semantic' ? 'UI8KIT' : 'Semantic'}
      </button>
    </div>
  );
}

3. Server-Side Usage

import { setTheme, getTheme } from '@buildy-ui/theme';

// Set theme on server
setTheme('semantic');

// Get current theme
const currentTheme = getTheme(); // 'semantic' | 'ui8kit'

API Reference

React Hooks

import { useTheme } from '@buildy-ui/theme';

const { 
  current,      // Current theme: 'semantic' | 'ui8kit'
  isLoading,    // Loading state
  setTheme,     // Set specific theme
  toggleTheme   // Toggle between themes
} = useTheme();

Theme Management

import { getTheme, setTheme } from '@buildy-ui/theme';

// Get current theme
const theme = getTheme(); // 'semantic' | 'ui8kit'

// Set theme
setTheme('semantic');
setTheme('ui8kit');

Storage Utilities

import { 
  getStoredTheme, 
  storeTheme, 
  getThemeFromUrl, 
  getInitialTheme 
} from '@buildy-ui/theme';

// Get theme from localStorage
const stored = getStoredTheme(); // ThemeType | null

// Store theme in localStorage
storeTheme('semantic');

// Get theme from URL parameter (?theme=semantic)
const urlTheme = getThemeFromUrl(); // ThemeType | null

// Get initial theme (URL > localStorage > default)
const initial = getInitialTheme(); // ThemeType

Constants & Types

import { THEME_TYPES, DEFAULT_THEME } from '@buildy-ui/theme';
import type { ThemeType, ThemeState } from '@buildy-ui/theme';

// Available themes
THEME_TYPES.SEMANTIC // 'semantic'
THEME_TYPES.UI8KIT   // 'ui8kit'

// Default theme
DEFAULT_THEME // 'ui8kit'

Server-Side Rendering

For SSR frameworks like Next.js, Remix, or Elysia:

import { ThemeProvider, setTheme, getTheme } from '@buildy-ui/theme';

// Set theme from URL parameter
app.use((req, res, next) => {
  const theme = req.query.theme;
  if (theme === 'semantic' || theme === 'ui8kit') {
    setTheme(theme);
  }
  next();
});

// Render with theme
function renderPage() {
  const currentTheme = getTheme();
  
  return (
    <ThemeProvider initialTheme={currentTheme}>
      <App />
    </ThemeProvider>
  );
}

Client-Side Initialization

Include the client script for automatic theme handling:

<script src="node_modules/@buildy-ui/theme/dist/client.js"></script>

Or import in your bundle:

import '@buildy-ui/theme/dist/client.js';

Theme Switching

Via URL Parameters

https://yoursite.com/?theme=semantic
https://yoursite.com/?theme=ui8kit

Programmatically

import { useTheme } from '@buildy-ui/theme';

function MyComponent() {
  const { setTheme, toggleTheme } = useTheme();
  
  return (
    <div>
      <button onClick={() => setTheme('semantic')}>
        Semantic Theme
      </button>
      <button onClick={() => setTheme('ui8kit')}>
        UI8KIT Theme
      </button>
      <button onClick={toggleTheme}>
        Toggle Theme
      </button>
    </div>
  );
}

TypeScript

Full TypeScript support with proper type definitions:

import type { ThemeType, ThemeState, ThemeAction } from '@buildy-ui/theme';

// Theme type is strictly typed
const theme: ThemeType = 'semantic'; // ✅
const invalid: ThemeType = 'custom'; // ❌ Type error

// State interface
const state: ThemeState = {
  current: 'ui8kit',
  isLoading: false
};

License

MIT

Contributing

Contributions welcome! Please read our contributing guidelines.