Joan León PRO
⚡️ Web Performance Consultant | Speaker | Staff Frontend Engineer at @AdevintaSpain | @GoogleDevExpert in #WebPerf | @cloudinary Ambassador
PostCSS Preset Env lets you convert modern CSS into something most browsers can understand, determining the polyfills you need based on your targeted browsers or runtime environments, using cssdb.
CSS features from the spec
Strawperson
Proposal
Draft
Candidate
Finished
0
1
2
3
4
Use tomorrow’s CSS today.
cssdb is a comprehensive list of CSS features and their positions in the process of becoming implemented web standards.
Stage 0: Aspirational
“This is a crazy idea.”
Stage 1: Experimental
“This idea might not be crazy.”
Stage 2: Allowable
“This idea is not crazy.”
Stage 3: Embraced
“This idea is becoming part of the web.”
Stage 4: Standardized
“This idea is part of the web.”
Rejected
“I had no idea what I was doing.”
Stage level
Name & Description
Link to Specification & MDN
Sample code
Browser support & Can I Use
Link to PostCSS plugin
all property
break properties
custom properties
font-variant property
gap properties
media query ranges
:any-link pseudo-class
case-insensitive attributes
:dir pseudo-class
double position gradients
:focus-visible pseudo-class
:focus-within pseudo-class
:focus-within pseudo-class
alpha hex colors
gray() function
hwb() function
image-set() function
lab() function
lch() function
logical properties and values
:matches pseudo-class
:not pseudo-class
overflow shorthand property
overflow-wrap property
place properties
rebeccapurple color
system-ui font family
:blank empty-value pseudo-class
functional color notation
custom media queries
custom selectors
nesting rules
prefers-color-scheme media query
custom environment variables
npm install postcss-preset-env --save-dev
Node.js | PostCSS CLI | Webpack | Create React App | Gulp | Grunt | Rollup
npm install postcss-cli --save-dev
const postcssPresetEnv = require('postcss-preset-env');
module.exports = {
plugins: [
postcssPresetEnv(/* pluginOptions */)
]
}
postcss.config.js
...
postcssPresetEnv({
stage: 3
})
...
postcss.config.js
...
postcssPresetEnv({
stage: 3,
features: {
"nesting-rules": true // Stage 1
}
})
...
postcss.config.js
...
postcssPresetEnv({
browsers: "last 2 versions",
stage: 3,
features: {
"nesting-rules": true // Stage 1
}
})
...
postcss.config.js
Use tomorrow’s CSS today.
By Joan León
With the PostCSS Preset Env project (based on cssdb) we can say that it is the Babel for CSS, with different states of the features as we have in EcmaScript. Finally we can focus on knowing and developing with the specifications that are being defined as CSS standards for the web.