Gathering detailed insights and metrics for postcss-nesting
Gathering detailed insights and metrics for postcss-nesting
Gathering detailed insights and metrics for postcss-nesting
Gathering detailed insights and metrics for postcss-nesting
@tailwindcss/nesting
A light wrapper around any postcss nesting plugin improves compatibility with Tailwind CSS.
@csstools/postcss-nesting-experimental
Nest rules inside each other in CSS (Draft : 28 October 2022)
stylelint-selector-bem-pattern
A stylelint plugin that harnesses the power of postcss-bem-linter
@rtkcd/ui-kit
``` yarn add -D autoprefixer postcss postcss-import postcss-nesting @rtkcd/tailwind-config tailwindcss ```
npm install postcss-nesting
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.4
Supply Chain
99.4
Quality
86.3
Maintenance
100
Vulnerability
100
License
CSS (43.25%)
JavaScript (30.24%)
TypeScript (22.9%)
HTML (3.03%)
Nunjucks (0.48%)
Shell (0.1%)
Total Downloads
1,720,051,916
Last Day
369,027
Last Week
6,769,007
Last Month
28,850,459
Last Year
330,068,123
MIT-0 License
981 Stars
4,379 Commits
78 Forks
9 Watchers
6 Branches
132 Contributors
Updated on Jun 30, 2025
Minified
Minified + Gzipped
Latest Version
13.0.2
Package Id
postcss-nesting@13.0.2
Unpacked Size
31.44 kB
Size
7.01 kB
File Count
7
NPM Version
10.9.0
Node Version
22.12.0
Published on
Jun 10, 2025
Cumulative downloads
Total Downloads
Last Day
-13.1%
369,027
Compared to previous day
Last Week
-8.9%
6,769,007
Compared to previous week
Last Month
2.8%
28,850,459
Compared to previous month
Last Year
-4.1%
330,068,123
Compared to previous year
1
npm install postcss-nesting --save-dev
PostCSS Nesting lets you nest style rules inside each other, following the CSS Nesting specification.
If you want nested rules the same way Sass works you might want to use PostCSS Nested instead.
1.foo { 2 color: red; 3 4 &:hover { 5 color: green; 6 } 7 8 > .bar { 9 color: blue; 10 } 11 12 @media (prefers-color-scheme: dark) { 13 color: cyan; 14 } 15 16 color: pink; 17} 18 19/* becomes */ 20 21.foo { 22 color: red; 23} 24.foo:hover { 25 color: green; 26 } 27.foo > .bar { 28 color: blue; 29 } 30@media (prefers-color-scheme: dark) { 31 .foo { 32 color: cyan; 33} 34 } 35.foo { 36 37 color: pink; 38}
Add PostCSS Nesting to your project:
1npm install postcss postcss-nesting --save-dev
Use it as a PostCSS plugin:
1const postcss = require('postcss'); 2const postcssNesting = require('postcss-nesting'); 3 4postcss([ 5 postcssNesting(/* pluginOptions */) 6]).process(YOUR_CSS /*, processOptions */);
The CSS nesting feature has gone through several iterations and what is currently implemented in browsers is not the same as what was originally proposed. This plugin dates back to the original proposal and you might have written your CSS expecting this older behavior.
You can pick the older behavior by setting the edition
option.
The edition
values correspond with rough dates when of a particular version of the specification:
2024-02
(default)2021
[!TIP] If you wrote nested rules with
@nest
you definitely want to set theedition
to2021
.
If you are unsure than you should try to omit theedition
option and use the default.
Eventually we will remove support for the older edition, and this plugin option, so it is strongly advised to update your CSS to the latest edition.
1postcssNesting({ 2 edition: '2024-02' 3})
2024-02
(default):is()
pseudo-class in the generated CSS is no longer optional. However you can add postcss-is-pseudo-class
to transpile furtherand
keyword@nest
is removed from the specification2021
This version is a continuation of what existed before CSS nesting was implemented in browsers.
It made a few non-invasive changes to keep up with implementations but it is falling behind.
1.foo { 2 color: red; 3 4 &:hover { 5 color: green; 6 } 7 8 > .bar { 9 color: blue; 10 } 11 12 @media (prefers-color-scheme: dark) { 13 color: cyan; 14 } 15 16 color: pink; 17} 18 19/* becomes */ 20 21.foo { 22 color: red; 23 24 color: pink; 25} 26.foo:hover { 27 color: green; 28 } 29.foo > .bar { 30 color: blue; 31 } 32@media (prefers-color-scheme: dark) { 33 .foo { 34 color: cyan; 35} 36 }
2021
)Before :
1#alpha, 2.beta { 3 &:hover { 4 order: 1; 5 } 6}
After without the option :
1postcssNesting()
1:is(#alpha,.beta):hover { 2 order: 1; 3}
.beta:hover
has specificity as if .beta
where an id selector, matching the specification.
After with the option :
1postcssNesting({ 2 noIsPseudoSelector: true 3})
1#alpha:hover, .beta:hover { 2 order: 1; 3}
.beta:hover
has specificity as if .beta
where a class selector, conflicting with the specification.
Before :
1.alpha > .beta { 2 & + & { 3 order: 2; 4 } 5}
After without the option :
1postcssNesting()
1:is(.alpha > .beta) + :is(.alpha > .beta) { 2 order: 2; 3}
After with the option :
1postcssNesting({ 2 noIsPseudoSelector: true 3})
1.alpha > .beta + .alpha > .beta { 2 order: 2; 3}
this is a different selector than expected as .beta + .alpha
matches .beta
followed by .alpha
.
avoid these cases when you disable :is()
writing the selector without nesting is advised here
1/* without nesting */ 2.alpha > .beta + .beta { 3 order: 2; 4}
No vulnerabilities found.
Reason
30 commit(s) and 8 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
1 existing vulnerabilities detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 1/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More