postcss-js alternatives and similar libraries
Based on the "CSS / Style" category.
Alternatively, view postcss-js alternatives based on common mentions on social networks and blogs.
-
styled-components
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅 -
classnames
A simple javascript utility for conditionally joining classNames together -
stitches
CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience. -
react-responsive
CSS media queries in react - for responsive design, and more. -
react-css-modules
Seamless mapping of class names to CSS modules inside of React components. -
aphrodite
Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation -
react-container-query
:package: Modular responsive component -
react-css-components
Define React presentational components with CSS -
react-look
Advanced & Dynamic Component Styling for React and React Native. Ships with powerful Plugins, Mixins and Developer Tools. -
inline-style-prefixer
Autoprefixer for JavaScript style objects -
stilr
Encapsulated styling for your javascript components with all the power of javascript and CSS combined. -
aesthetic
🎨 Aesthetic is an end-to-end multi-platform styling framework that offers a strict design system, robust atomic CSS-in-JS engine, a structural style sheet specification (SSS), a low-runtime solution, and much more! -
paperclip
Write durable HTML & CSS for any kind of web application [Moved to: https://github.com/paperclip-ui/paperclip] -
reactponsive
Responsive components and Hooks ⚒ for your favorite framework ⚛️
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of postcss-js or a related project?
README
PostCSS JS
PostCSS for CSS-in-JS and styles in JS objects.
For example, to use Stylelint or RTLCSS plugins in your workflow.
Usage
Processing
const postcssJs = require('postcss-js')
const autoprefixer = require('autoprefixer')
const prefixer = postcssJs.sync([ autoprefixer ])
const style = prefixer({
userSelect: 'none'
})
style //=> {
// WebkitUserSelect: 'none',
// MozUserSelect: 'none',
// msUserSelect: 'none',
// userSelect: 'none'
// }
Compile CSS-in-JS to CSS
const postcss = require('postcss')
const postcssJs = require('postcss-js')
const style = {
top: 10,
'&:hover': {
top: 5
}
};
postcss().process(style, { parser: postcssJs }).then( (result) => {
result.css //=> top: 10px;
// &:hover { top: 5px; }
})
Compile CSS to CSS-in-JS
const postcss = require('postcss')
const postcssJs = require('postcss-js')
const css = '--text-color: #DD3A0A; @media screen { z-index: 1; color: var(--text-color) }'
const root = postcss.parse(css)
postcssJs.objectify(root) //=> {
// '--text-color': '#DD3A0A',
// '@media screen': {
// zIndex: '1',
// color: 'var(--text-color)'
// }
// }
API
sync(plugins): function
Create PostCSS processor with simple API, but with only sync PostCSS plugins support.
Processor is just a function, which takes one style object and return other.
async(plugins): function
Same as sync
, but also support async plugins.
Returned processor will return Promise.
parse(obj): Root
Parse CSS-in-JS style object to PostCSS Root
instance.
It converts numbers to pixels and parses [Free Style] like selectors and at-rules:
{
'@media screen': {
'&:hover': {
top: 10
}
}
}
This methods use Custom Syntax name convention, so you can use it like this:
postcss().process(obj, { parser: postcssJs })
objectify(root): object
Convert PostCSS Root
instance to CSS-in-JS style object.
Troubleshoot
Webpack may need some extra config for some PostCSS plugins.
Module parse failed
Autoprefixer and some other plugins need a json-loader to import data.
So, please install this loader and add to webpack config:
loaders: [
{
test: /\.json$/,
loader: "json-loader"
}
]