postcss-pseudo-is
v0.3.0
Published
PostCSS plugin to transform the :is() CSS pseudo-class into more compatible CSS selectors.
Downloads
402,728
Maintainers
Readme
PostCSS Pseudo Is
PostCSS plugin to transform the :is() CSS pseudo-class into more compatible CSS selectors.
Example
Write less
.button:is(:hover, :focus, :active) {
/* Input example */
}
.button:hover,
.button:focus,
.button:active {
/* Output example */
}
Simplify
:is(section, article, aside, nav)
:is(section, article, aside, nav) h1 {
/* Input example */
}
section section h1, section article h1, section aside h1, section nav h1,
article section h1, article article h1, article aside h1, article nav h1,
aside section h1, aside article h1, aside aside h1, aside nav h1,
nav section h1, nav article h1, nav aside h1, nav nav h1 {
/* Output example */
}
Install
npm i -D postcss postcss-pseudo-is
or
yarn add -D postcss postcss-pseudo-is
:warning: Warning :warning:
This is not an implementation or a polyfill for the :is()
pseudo-class but a very simple syntax-sugar.
It has a huge amount of limitations thus please do not use any complex selector you may want to use.
Usage
Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss"
section in package.json
or postcss
in bundle config.
If you already use PostCSS, add the plugin to plugins list:
module.exports = {
plugins: [
+ require('postcss-pseudo-is'),
require('autoprefixer')
]
}
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Limitations
- The specificity of the
:is()
pseudo-class is not replaced by the specificity of its most specific argument - Not avoiding selector list invalidation
- Can't handle complex selectors
- And much more...