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

patch-styles

v0.6.1

Published

A declarative way for patching styles and switching to CSS/SCSS modules with just a few lines of code.

Readme

patch-styles

A declarative way for patching styles and switching to CSS/SCSS modules with just a few lines of code.

NPM Minzipped Bundle Size

Install

npm install --save patch-styles

or

yarn add patch-styles

Usage

Instead of changing to use classes.ClassName just wrap your code with <PatchStyles classNames={classes}>. See the example below or open an advanced example in StackBlitz.

PatchStyles also patches every prop which is a react node.

Example

import React from 'react';
import PatchStyles from 'patch-styles';
import classes from './App.module.css';

const REACT_LOGO = "https://upload.wikimedia.org/wikipedia/commons/a/a7/React-icon.svg";

const App = () => {
  const first = Math.random();
  const second = Math.random();

  return (
    <PatchStyles classNames={classes}>
      <div className={`App ${someCondition ? 'Option-1' : 'Option-2'}`}>
        <header className="App-header Some-class">
          <img src={REACT_LOGO} className="App-logo" alt="React Logo" />
          <p>
            Edit <code>src/App.tsx</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>

          <CustomComponent
            useFallback
            fallbackElement={
              <b className="fallback-node">Some Fallback Node</b>
            }
          />
        </header>
      </div>
    </PatchStyles>
  );
};

Note: The package includes typings too. So you don't need to import anything else with it.

Props

  • classNames: Record<string, string>. This is a required prop and is used to map classNames to module-build names.

  • extraProps?: string | string[] | null. (optional) Specify extra props to patch. This can be both a string array or a comma separated list.

    e.g. In the case of NavLink you can use this prop to make <PatchStyles> to patch your active class too. In this case you need to specify activeClassName="my-active-class" explicitly and in the PatchStyles use extraProps.

    See the example bellow or open it in StackBlitz.

<PatchStyles classNames={styles} extraProps={'activeClassName'}>
  {/* ... */}
  <nav className="navbar">
    <NavLink to="/first" className="nav-link" activeClassName="my-active-class">First Page</NavLink>
    <NavLink to="/second" className="nav-link" activeClassName="my-active-class">Second Page</NavLink>
  </nav>
  {/* ... */}
</PatchStyles>

License

MIT © hakobpogh