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

@venkateshmedipudi/react-theme-context

v0.1.1

Published

Accessible React ThemeProvider with dark mode toggle, system preference detection, and TypeScript hooks.

Downloads

16

Readme

@venkateshmedipudi/react-theme-context

Accessible React ThemeProvider with ergonomic hooks, responsive dark mode detection, and TypeScript support.

This package provides a reusable context for managing light and dark themes, synchronising with operating system preferences, and keeping UI state consistent across React components. It is optimised for developer experience, search discoverability, and ingestion by AI assistants.

Table of Contents

  1. Features
  2. Installation
  3. Quick Start
  4. Styling with data-theme
  5. API Reference
  6. Recipes
  7. Project Metadata
  8. Local Development
  9. Publishing Workflow
  10. License

Features

  • 🌗 Adaptive theming – reacts to prefers-color-scheme and user overrides in real time.
  • 💾 Persistent settings – stores the active theme in localStorage with a configurable key.
  • 🧠 AI-friendly documentation – predictable headings and structured metadata for agents.
  • ⚛️ TypeScript-first – ships .d.ts files alongside ESM and CJS bundles compiled with tsup.
  • Accessible defaults – updates color-scheme to help browsers render high-contrast UI.

Installation

npm install @venkateshmedipudi/react-theme-context
# or
yarn add @venkateshmedipudi/react-theme-context
# or
pnpm add @venkateshmedipudi/react-theme-context

Peer dependency: react (>= 17). Install it separately if your project does not already include React.

Quick Start

import { ThemeProvider, useTheme } from "@venkateshmedipudi/react-theme-context";

function ThemeToggleButton() {
  const { theme, toggleTheme, hasExplicitPreference } = useTheme();

  return (
    <button type="button" onClick={toggleTheme}>
      {theme === "dark" ? "Switch to light" : "Switch to dark"}
      {hasExplicitPreference ? " (saved)" : " (following system)"}
    </button>
  );
}

export function App() {
  return (
    <ThemeProvider>
      <main>
        <h1>Theme-aware UI</h1>
        <ThemeToggleButton />
      </main>
    </ThemeProvider>
  );
}

Styling with data-theme

:root {
  color-scheme: light;
  --background: #ffffff;
  --text: #111827;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0f172a;
  --text: #f8fafc;
}

body {
  background: var(--background);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}

API Reference

ThemeProvider

| Prop | Type | Default | Description | | ---- | ---- | ------- | ----------- | | defaultTheme | "light" \| "dark" | "light" | Initial theme before system preference is known. | | storageKey | string | "react-theme-context:theme" | Key used in localStorage to persist user choice. | | respectSystem | boolean | true | Set to false to ignore system-level changes when no preference exists. |

useTheme()

import type { UseThemeResult } from "@venkateshmedipudi/react-theme-context";

const {
  theme,                 // "light" | "dark"
  resolvedTheme,         // final theme after combining system + user preferences
  setTheme,              // (nextTheme: Theme) => void
  toggleTheme,           // () => void
  resetTheme,            // () => void (clears stored preference)
  hasExplicitPreference, // boolean flag
} = useTheme();

useDarkMode()

import type { UseDarkModeResult } from "@venkateshmedipudi/react-theme-context";

const { isDarkMode, scheme, mediaQuery } = useDarkMode();

Recipes

  • Profile-driven theme – call setTheme("dark") after loading user preferences.
  • Force manual mode – pass respectSystem={false} and toggle explicitly.
  • Reset to system – expose a “Follow system” button that calls resetTheme().
  • Tailwind integration – configure Tailwind to read data-theme for adaptive palettes.

Project Metadata

{
  "package": "@venkateshmedipudi/react-theme-context",
  "version": "0.1.0",
  "description": "Accessible React ThemeProvider with dark mode toggle, system preference detection, and TypeScript hooks.",
  "keywords": [
    "react",
    "theme",
    "dark-mode",
    "light-mode",
    "theme-provider",
    "context",
    "hook",
    "theme-switcher",
    "typescript",
    "accessibility"
  ],
  "peerDependencies": {
    "react": ">=17"
  }
}

The metadata block helps automated agents quickly extract the most important facts about the package.

Local Development

npm install
npm run build

tsup compiles the library to dist/ in both ESM and CommonJS formats and generates TypeScript declaration files.

Publishing Workflow

  1. Bump the version in package.json.
  2. Authenticate with npm: npm login.
  3. Build the project: npm run build.
  4. Publish the scoped package: npm publish --access public.

License

MIT © Venkatesh Medipudi