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

@jarviisha/davinci-react-theme-provider

v0.2.0

Published

React theme provider (light/dark/system) for the Davinci design system.

Readme

@jarviisha/davinci-react-theme-provider

A small, SSR-safe React theme provider for the Davinci design system. Supports light, dark, and system themes, persists the choice in localStorage, and ships a tiny inline script to avoid theme flash on reload.

Part of the Davinci design system. See DESIGN.md for the theming model these providers sit on top of.

Install

pnpm add @jarviisha/davinci-react-theme-provider

Peer dependencies: react ^18.3.1 || ^19.0.0, react-dom ^18.3.1 || ^19.0.0.

Usage

Wrap your app once:

import { ThemeProvider, useTheme } from "@jarviisha/davinci-react-theme-provider";

export function Root() {
  return (
    <ThemeProvider defaultTheme="system">
      <App />
    </ThemeProvider>
  );
}

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

ThemeProvider adds the light or dark class to <html> based on the active theme.

API

<ThemeProvider>

| Prop | Type | Default | Description | | -------------- | --------------------------------- | ---------------- | ------------------------------------------------- | | defaultTheme | "light" \| "dark" \| "system" | "system" | Theme used when nothing is stored. | | storageKey | string | "davinci-theme" | localStorage key for persistence. |

useTheme()

const { theme, resolvedTheme, setTheme } = useTheme();
  • theme — the user's preference (light, dark, or system).
  • resolvedTheme — the concrete theme currently applied (light or dark).
  • setTheme(next) — update the preference; persists to localStorage.

Avoid theme flash

ThemeProvider applies the theme class on mount, which causes a brief flash for dark-mode users. Inject a tiny synchronous script in <head> so the class lands before first paint.

Next.js, Remix, Astro — render ThemeScript inside <head>:

import { ThemeScript } from "@jarviisha/davinci-react-theme-provider";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head>
        <ThemeScript defaultTheme="system" />
      </head>
      <body>{children}</body>
    </html>
  );
}

Plain HTML (Vite, CRA) — inline the output of getThemeScript():

import { getThemeScript } from "@jarviisha/davinci-react-theme-provider";
console.log(getThemeScript({ defaultTheme: "system" }));
// Paste the printed string into your index.html <head>.

Pass the same defaultTheme and storageKey to ThemeScript (or getThemeScript) and ThemeProvider so they agree.

Radius customization

useRadiusPreset adjusts the Davinci radius scale at runtime. It accepts a named preset (minimum, subtle, default, bold) or a raw { sm, md, lg, xl } scale in pixels, writes the --davinci-radius-* (and derived --davinci-semantic-radius-*) custom properties on <html>, and persists the choice to localStorage.

import { useRadiusPreset, matchPreset } from "@jarviisha/davinci-react-theme-provider";

function RadiusControls() {
  const [radius, setRadius] = useRadiusPreset();
  const active = matchPreset(radius); // preset key, or null when custom

  return (
    <>
      <button onClick={() => setRadius("bold")}>Bold</button>
      {/* free-form: bump just one step */}
      <button onClick={() => setRadius({ sm: 6, md: 10, lg: 14, xl: 20 })}>Custom</button>
      <span>{active ?? "Custom"}</span>
    </>
  );
}

| Export | Description | | ----------------------- | --------------------------------------------------------------------------- | | useRadiusPreset(opts) | Hook returning [value, setValue]. Options: storageKey, defaultValue. | | radiusPresets | The named preset → scale map. | | resolveScale(value) | Resolve a preset key or scale to concrete { sm, md, lg, xl } pixels. | | matchPreset(value) | The preset a value matches exactly, or null when it is custom. | | RADIUS_PRESET_LABELS | Human-readable labels for each preset. | | getRadiusScript(opts) / RadiusScript | Flash-prevention script, same pattern as getThemeScript / ThemeScript. |

The default storageKey is "davinci-radius".

License

MIT