Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
postcss-scoped-styles
Advanced tools
Scope every selector within CSS with a class. Can either be a unique, randomized class per CSS file (default), or can be a class of your choosing.
Scope every selector within CSS with a class. Can either be a unique, randomized class per CSS file (default), or can be a class of your choosing.
Fast, lightweight, and zero dependencies.
npm i postcss-scoped-styles
// postcss.config.mjs
import postcssScopedStyles from 'postcss-scoped-styles';
export default {
plugins: [postcssScopedStyles()],
};
Any and all selectors you use will now be scoped:
- h1 {
+ h1.gZHu1x {
font-size: 32px;
}
- .button {
+ .button.gZHu1x {
color: blue;
}
- #text-input {
+ #text-input.gZHu1x {
font-family: monospace;
}
However, you may opt out of this with the :global()
selector (i.e. will remain as-written):
- :global(.button:hover) {
+ .button:hover {
color: blue;
}
It’s also important to note that html
and body
won’t be scoped either, as they can only appear in the document once (it also makes selecting them easier).
scopedClass
By default, a random 6-character class is added for each CSS document. You may customize that by providing a scopedClass()
function that returns a string:
// postcss.config.mjs
import postcssScopedStyles from 'postcss-scoped-styles';
export default {
plugins: [
postcssScopedStyles({
scopedClass({ uuid, selector }) {
return `my-scoped-class-${uuid}`; // .my-scoped-class-c10a6a
},
}),
],
};
The callback provides uuid
and selector
in an object param for extra context, but you don’t have to use these to generate the class. uuid
is the random string that would have been applied on its own. It will be randomized on every pass, but it will stay consistent within each CSS document.
FAQs
Scope every selector within CSS with a class. Can either be a unique, randomized class per CSS file (default), or can be a class of your choosing.
The npm package postcss-scoped-styles receives a total of 0 weekly downloads. As such, postcss-scoped-styles popularity was classified as not popular.
We found that postcss-scoped-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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.