
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
patch-styles
Advanced tools
A declarative way for patching styles and switching to CSS/SCSS modules with just a few lines of code.
A declarative way for patching styles and switching to CSS/SCSS modules with just a few lines of code.
npm install --save patch-styles
or
yarn add patch-styles
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.
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.
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>
MIT © hakobpogh
FAQs
A declarative way for patching styles and switching to CSS/SCSS modules with just a few lines of code.
We found that patch-styles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.