Gathering detailed insights and metrics for css-blank-pseudo
Gathering detailed insights and metrics for css-blank-pseudo
Gathering detailed insights and metrics for css-blank-pseudo
Gathering detailed insights and metrics for css-blank-pseudo
npm install css-blank-pseudo
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.5
Supply Chain
99.4
Quality
81
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,476,962,264
Last Day
329,091
Last Week
5,859,159
Last Month
24,961,323
Last Year
285,902,139
MIT-0 License
982 Stars
4,379 Commits
78 Forks
9 Watchers
6 Branches
132 Contributors
Updated on Jul 04, 2025
Minified
Minified + Gzipped
Latest Version
7.0.1
Package Id
css-blank-pseudo@7.0.1
Unpacked Size
48.04 kB
Size
10.37 kB
File Count
13
NPM Version
10.7.0
Node Version
22.1.0
Published on
Oct 23, 2024
Cumulative downloads
Total Downloads
Last Day
-13.5%
329,091
Compared to previous day
Last Week
-9.3%
5,859,159
Compared to previous week
Last Month
3.6%
24,961,323
Compared to previous month
Last Year
-8%
285,902,139
Compared to previous year
1
1
npm install css-blank-pseudo --save-dev
PostCSS Blank Pseudo lets you style form elements when they are empty, following the Selectors Level 4 specification.
To use this feature you need to do two things :
1input:blank { 2 background-color: yellow; 3} 4 5/* becomes */ 6 7input[blank].js-blank-pseudo, .js-blank-pseudo input[blank] { 8 background-color: yellow; 9} 10input:blank { 11 background-color: yellow; 12}
Add PostCSS Blank Pseudo to your project:
1npm install postcss css-blank-pseudo --save-dev
Use it as a PostCSS plugin:
1const postcss = require('postcss'); 2const postcssBlankPseudo = require('css-blank-pseudo'); 3 4postcss([ 5 postcssBlankPseudo(/* pluginOptions */) 6]).process(YOUR_CSS /*, processOptions */);
The preserve
option determines whether the original notation
is preserved. By default, it is preserved.
1postcssBlankPseudo({ preserve: false })
1input:blank { 2 background-color: yellow; 3} 4 5/* becomes */ 6 7input[blank].js-blank-pseudo, .js-blank-pseudo input[blank] { 8 background-color: yellow; 9}
The replaceWith
option determines the selector to use when replacing
the :blank
pseudo. By default is [blank]
1postcssBlankPseudo({ replaceWith: '.css-blank' })
1input:blank { 2 background-color: yellow; 3} 4 5/* becomes */ 6 7.foo { 8 color: blue; 9 color: red; 10} 11 12.baz { 13 color: green; 14}
Note that changing this option implies that it needs to be passed to the browser polyfill as well.
The disablePolyfillReadyClass
option determines if selectors are prefixed with an indicator class.
This class is only set on your document if the polyfill loads and is needed.
By default this option is false
.
Set this to true
to prevent the class from being added.
1postcssBlankPseudo({ disablePolyfillReadyClass: true })
1input:blank { 2 background-color: yellow; 3} 4 5/* becomes */ 6 7input[blank] { 8 background-color: yellow; 9} 10input:blank { 11 background-color: yellow; 12}
1import cssBlankPseudoInit from 'css-blank-pseudo/browser'; 2 3cssBlankPseudoInit();
or
1<!-- When using a CDN url you will have to manually update the version number --> 2<script src="https://unpkg.com/css-blank-pseudo@7.0.1/dist/browser-global.js"></script> 3<script>cssBlankPseudoInit()</script>
PostCSS Blank Pseudo works in all major browsers, including Safari 6+ and Internet Explorer 9+ without any additional polyfills.
This plugin conditionally uses MutationObserver
to ensure recently inserted
inputs get correct styling upon insertion. If you intend to rely on that
behaviour for browsers that do not support MutationObserver
, you have two
options:
MutationObserver
. As long as it runs before cssBlankPseudoInit
,
the polyfill will work.MutationObserver
you can also manually fire
a change
event upon insertion so they're automatically inspected by the
polyfill.The force
option determines whether the library runs even if the browser
supports the selector or not. By default, it won't run if the browser does
support the selector.
1cssBlankPseudoInit({ force: true });
Similar to the option for the PostCSS Plugin, replaceWith
determines the
attribute or class to apply to an element when it's considered to be :blank
.
1cssBlankPseudoInit({ replaceWith: '.css-blank' });
This option should be used if it was changed at PostCSS configuration level.
Please note that using a class, leverages classList
under the hood which
might not be supported on some old browsers such as IE9, so you may need
to polyfill classList
in those cases.
Given that Next.js imports packages both on the browser and on the server, you need to make sure that the package is only imported on the browser.
As outlined in the Next.js documentation, you need to load the package with a dynamic import:
1useEffect(async () => { 2 const cssBlankPseudoInit = (await import('css-blank-pseudo/browser')).default; 3 cssBlankPseudoInit(); 4}, []);
We recommend you load the polyfill as high up on your Next application as possible, such as your pages/_app.ts
file.
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