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

@raypx-kit/themes

v0.0.0-alpha.1

Published

Neutral theme tokens, safe first-paint scripts, and React theme state.

Readme

@raypx-kit/themes

Neutral semantic tokens, a first-paint theme script, and React 19 theme state. The package has no application reset, picker, icon, Tailwind runtime, or product dependencies.

Install and styles

bun add @raypx-kit/themes react

For plain CSS, import @raypx-kit/themes/styles.css. It defines semantic custom properties such as --background, --foreground, --primary, --destructive-text, --radius, and the complete chart/sidebar palette.

For Tailwind 4, import the engine once in your application, then the mapping:

@import "tailwindcss";
@import "@raypx-kit/themes/tailwind.css";

The mapping imports the base tokens and exposes bg-background, text-foreground, text-destructive-text, radius, shadow, and other semantic utilities. It does not import Tailwind itself. Applications may override the custom properties after the package import. No body, heading, control, or font reset is included.

React and first paint

import { ThemeProvider, ThemeScript, useTheme } from "@raypx-kit/themes";

function Document({ children }: { children: React.ReactNode }) {
  return (
    <html suppressHydrationWarning>
      <head>
        <ThemeScript storageKey="my-app-theme" />
      </head>
      <body>
        <ThemeProvider storageKey="my-app-theme">{children}</ThemeProvider>
      </body>
    </html>
  );
}

function Toggle() {
  const { theme, resolvedTheme, setTheme } = useTheme();
  return (
    <button onClick={() => setTheme(resolvedTheme === "dark" ? "light" : "dark")}>{theme}</button>
  );
}

Use the same initialTheme and storageKey for the script and provider. initialTheme defaults to system and supplies the server-rendered snapshot and the fallback when no valid persisted preference exists. Hydration starts from that server snapshot, then reconciles local preferences. storageKey={false} keeps changes in memory while still allowing the first-paint script to apply an explicit or system theme. ThemeScript accepts a CSP nonce.

The preference is light, dark, or system; resolvedTheme is always light or dark. Valid localStorage wins over the cookie mirror, then initialTheme. The provider follows system changes, handles cross-tab storage events, and removes its subscriptions on unmount. Storage failures do not prevent switching. readStoredTheme(fallback?, storageKey?) and storeTheme(theme, storageKey?) are available for non-React persistence; use setTheme to update a mounted provider. Cookie persistence uses a URL-encoded key, Path=/, a one-year lifetime and SameSite=Lax.

The script/provider set .light or .dark, data-theme, color-scheme, and one theme-color meta tag. Explicit root classes take precedence over the CSS system media fallback. Render the script before the application styles paint. Do not render a React-owned theme-color meta tag: React 19 may duplicate a tag whose content the first-paint script changed. themeMeta supplies a safe color-scheme meta descriptor instead.

React-free entries

import { readThemeCookie, themeTokens, type UserTheme } from "@raypx-kit/themes/config";
import { createThemeScript } from "@raypx-kit/themes/script";

const preference: UserTheme = readThemeCookie(request.headers.get("cookie")) ?? "system";
const inlineScript = createThemeScript({ initialTheme: preference });

/config exports themeTokens, ThemeToken, themeColors, themeMeta, THEME_STORAGE_KEY, UserTheme, AppTheme, parseTheme, and readThemeCookie. /script exports createThemeScript and ThemeScriptOptions. Neither entry requires React or browser globals. Interpolated script data escapes HTML-closing characters; arbitrary JavaScript source expressions are not accepted.

Maintenance

src/tokens.ts is the single source for both CSS artifacts. Run bun run generate:theme after token changes; check and build reject stale generated files. Node 22.21 or newer is supported. React is an optional peer for the pure entries and is required when importing the root React entry.

Licenses

LICENSE contains this package's Apache-2.0 terms, and NOTICE retains the adapted source's provenance. Both ship in the npm archive. The React peer remains an external dependency with its own license file.

The index below records installed direct runtime dependencies and peers, with links to their licenses. Their full texts are not duplicated here. Run bun run licenses:update from the repository root after dependency changes; bun run licenses:check rejects a stale index.

| Package | Installed version | License | License text | | ------- | ----------------- | ------- | ------------------------------------------------- | | react | 19.3.1 | MIT | LICENSE |

Browser E2E

The first-paint script, hydration, reload persistence, real cross-tab synchronization and system preferences.

Run bun run test:e2e:install once at the repository root, then bun run --cwd packages/themes test:e2e. The package owns its scenarios in e2e/; see the browser test guide for project selection, reports and CI behavior.