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

now-design-theme

v1.0.5

Published

Theme provider and utilities for Now Design System

Readme

now-design-theme

A focused React theming solution for the Now Design System. Provides a ThemeProvider and useTheme hook for robust, flexible, and scalable theming in your React app.


🎨 What is now-design-theme?

A lightweight, context-based theming provider for React. Supports light/dark/custom themes, dynamic switching, and seamless integration with CSS variables and design tokens.


📦 Installation

npm install now-design-theme

⚡ Quick Start

Note: The ThemeProvider sets the data-theme attribute on the <body> element, ensuring global theming for your entire app (including modals, overlays, and portals).

import { ThemeProvider, useTheme } from 'now-design-theme';

function ThemeToggle() {
  const { theme, toggleTheme } = useTheme();
  return (
    <button onClick={toggleTheme}>
      Switch to {theme === 'light' ? 'Dark' : 'Light'} mode
    </button>
  );
}

function App() {
  return (
    <ThemeProvider defaultTheme="light">
      <ThemeToggle />
      {/* ...rest of your app */}
    </ThemeProvider>
  );
}

🏗️ Theming Concepts

  • Global Theming: The ThemeProvider sets data-theme on <body>, so all CSS variables and styles respond to theme changes everywhere in your app.
  • Theme: A set of design values (colors, backgrounds, etc.) applied via CSS variables or class names.
  • ThemeProvider: React context provider that injects theme variables and manages theme state.
  • useTheme: Hook to access and control the current theme.
  • Dynamic Switching: Toggle between themes (e.g., light/dark) at runtime.
  • Custom Themes: Extend or override built-in themes with your own values.

Why this approach? Setting data-theme on <body> ensures that all parts of your app—including global styles, modals, overlays, and portals—respond to theme changes. This is more robust than wrapping your app in a <div data-theme={theme}>.


🧩 API Reference

<ThemeProvider />

| Prop | Type | Default | Description | |----------------|----------|-----------|------------------------------------| | defaultTheme | string | 'light' | Initial theme ('light', 'dark', etc.) | | theme | object | undefined | Custom theme object (optional) | | children | ReactNode| — | App content |

useTheme()

Returns an object:

{
  theme,        // Current theme name
  setTheme,     // Function to set a specific theme
  toggleTheme,  // Function to toggle between themes
  themes        // Array of available themes
}

🚀 Advanced Theming

Custom Themes

const myTheme = {
  primary: '#123456',
  background: '#f0f0f0',
  text: '#222',
  // ...other variables
};

<ThemeProvider theme={myTheme} defaultTheme="light">
  <App />
</ThemeProvider>

Dynamic Theme Switching

  • Use toggleTheme or setTheme from useTheme to switch themes on user action or system preference.

CSS Variables & Integration

  • The provider injects CSS variables for all theme values at the root or a theme selector.
  • Works seamlessly with now-design-tokens for consistent design values.

📝 Examples

Toggle Button

function ThemeToggle() {
  const { theme, toggleTheme } = useTheme();
  return (
    <button onClick={toggleTheme}>
      Switch to {theme === 'light' ? 'Dark' : 'Light'}
    </button>
  );
}

Using Theme in Styled Components

import styled from 'styled-components';

const ThemedBox = styled.div`
  background: var(--background);
  color: var(--text);
`;

🛠️ Troubleshooting

  • Theme not updating? Ensure your app is wrapped in <ThemeProvider>.
  • Context not found? Only call useTheme inside a child of <ThemeProvider>.
  • Custom theme not applied? Check your theme object structure and variable names.

🤝 Contributing

  • Add new themes, extend the provider, or improve documentation via PRs.
  • Please ensure all code is tested and documented.

License

MIT