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
83
Maintenance
100
Vulnerability
100
License
CSS (43.36%)
JavaScript (30.33%)
TypeScript (22.68%)
HTML (3.06%)
Nunjucks (0.48%)
Shell (0.1%)
Total Downloads
1,697,610,643
Last Day
1,183,615
Last Week
6,409,186
Last Month
27,637,082
Last Year
328,793,572
MIT-0 License
960 Stars
4,266 Commits
75 Forks
9 Watchers
4 Branches
130 Contributors
Updated on May 09, 2025
Minified
Minified + Gzipped
Latest Version
13.0.1
Package Id
postcss-nesting@13.0.1
Unpacked Size
31.66 kB
Size
7.03 kB
File Count
7
NPM Version
10.7.0
Node Version
22.1.0
Published on
Oct 23, 2024
Cumulative downloads
Total Downloads
Last Day
48.5%
1,183,615
Compared to previous day
Last Week
4.9%
6,409,186
Compared to previous week
Last Month
-6.4%
27,637,082
Compared to previous month
Last Year
-5.4%
328,793,572
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 is no longer optionaland
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 6 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
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 0/24 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-05-05
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