talira

A tool for transforming CSS with JavaScript

open sourceMITself-hostablefree

PostCSS parses CSS into an abstract syntax tree and runs JavaScript plugins over it, so one pipeline can add vendor prefixes, compile future CSS for today's browsers, scope class names, lint, inline images and minify. It does nothing by itself: its value is its 200-plus plugins, among them Autoprefixer, postcss-preset-env, CSS Modules, postcss-nested and Stylelint, and the plugin API that lets you write your own. Custom parsers let it read SCSS, Less, Sass's indented syntax, CSS in HTML and Markdown, and CSS-in-JS template literals. It runs inside webpack, Parcel, Rollup, Gulp and most other build tools, or from the command line with postcss-cli, and frameworks such as Tailwind CSS ship as PostCSS plugins. It's MIT-licensed, created by Andrey Sitnik and built by Evil Martians.

Problems it solves

  • add vendor prefixes to my CSS automatically for the browsers we support
  • use modern CSS features like nesting and oklch colours and still support older browsers
  • write a small build step that rewrites every url() in our stylesheets
  • scope class names per component so generic names never clash
  • lint our stylesheets for invalid colours and enforce team conventions in CI
  • run several CSS transforms in one pass inside our existing webpack or Vite build
  • write my own CSS transformation as a plugin instead of regex replacements on stylesheets
  • parse SCSS, Less or CSS inside template literals so tools can analyse and rewrite it
  • process stylesheets from npm scripts on the command line without a bundler

Features

  • CSS parser and stringifier with an AST API for plugins
  • more than 200 plugins, including Autoprefixer, postcss-preset-env, CSS Modules, postcss-nested and Stylelint
  • custom syntaxes for SCSS, Sass, Less, SugarSS, HTML, Markdown and CSS-in-JS
  • postcss-safe-parser finds and fixes CSS syntax errors
  • postcss-cli for the command line and npm scripts
  • integrations for webpack, Parcel, Gulp, Rollup, Grunt, Svelte and more
  • source maps
  • postcss-js applies PostCSS plugins to CSS-in-JS style objects
  • documented plugin and runner guidelines for writing your own

Limitations

  • Doesn't compile SCSS, Sass or Less to CSS: its SCSS, Sass and Less syntaxes only parse them for other plugins1

Capabilities

Has a command line toolplan not known
Takes pluginsplan not known

Alternatives

The same job

These do what PostCSS does.

  1. Lightning CSS An extremely fast CSS parser, transformer, bundler, and minifier
  2. Sass CSS with superpowers

Compare PostCSS with the top 3