polished vs styled-components vs emotion vs styled-system
CSS-in-JS Libraries Comparison
1 Year
polishedstyled-componentsemotionstyled-systemSimilar Packages:
What's CSS-in-JS Libraries?

CSS-in-JS libraries allow developers to write CSS styles directly within JavaScript files, enabling dynamic styling based on component state and props. This approach enhances the maintainability and scalability of styles in modern web applications. These libraries often support features like theming, scoped styles, and server-side rendering, making them suitable for complex applications that require a high degree of customization and flexibility in styling.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
polished6,567,5937,6412.8 MB28a year agoMIT
styled-components5,004,76940,6711.66 MB31214 days agoMIT
emotion531,683---4 years agoMIT
styled-system515,605---5 years agoMIT
Feature Comparison: polished vs styled-components vs emotion vs styled-system

Dynamic Styling

  • polished:

    Polished enhances existing CSS-in-JS libraries by providing utility functions that simplify the creation of dynamic styles. It allows developers to easily manipulate styles based on conditions, making it easier to implement responsive designs.

  • styled-components:

    Styled-Components supports dynamic styling through props, enabling developers to create styles that change based on component state. This feature is particularly useful for building interactive UI components that respond to user actions.

  • emotion:

    Emotion excels in dynamic styling, allowing styles to be defined based on component props and state. This enables developers to create highly interactive and responsive components that adapt to user interactions seamlessly.

  • styled-system:

    Styled-System focuses on responsive design and theming, allowing developers to create dynamic styles that adjust based on screen size and design tokens. It provides a powerful API for building responsive components.

Theming Support

  • polished:

    Polished does not provide theming support directly, but it can be used alongside other libraries that do. It enhances the theming capabilities of existing solutions by providing utility functions for common styling tasks.

  • styled-components:

    Styled-Components has robust theming support, enabling developers to define a theme object and use it within styled components. This feature promotes consistency and makes it easier to manage styles across large applications.

  • emotion:

    Emotion provides built-in theming support, allowing developers to define a theme and access it throughout their application. This feature simplifies the process of maintaining consistent styles across components.

  • styled-system:

    Styled-System is designed with theming in mind, allowing developers to create a design system with reusable style tokens. This makes it easy to maintain a consistent look and feel across an application.

Learning Curve

  • polished:

    Polished is relatively easy to learn, especially for developers already using a CSS-in-JS library. Its utility-first approach makes it intuitive to use, as it provides straightforward functions for common styling tasks.

  • styled-components:

    Styled-Components has a gentle learning curve, particularly for those familiar with React. Its component-based approach to styling is intuitive, making it easy to grasp for new users.

  • emotion:

    Emotion has a moderate learning curve, especially for developers familiar with CSS-in-JS concepts. Its flexibility in syntax (CSS prop and styled components) allows for a smooth transition for those coming from traditional CSS.

  • styled-system:

    Styled-System may have a steeper learning curve due to its focus on responsive design and theming. However, once understood, it offers powerful tools for building scalable design systems.

Performance

  • polished:

    Polished adds minimal overhead to your styles, as it primarily provides utility functions. Its impact on performance is negligible, making it a lightweight addition to your styling solution.

  • styled-components:

    Styled-Components has made significant improvements in performance, particularly with its latest versions. It uses a unique approach to style injection that minimizes re-renders and optimizes the rendering process.

  • emotion:

    Emotion is optimized for performance, using a highly efficient runtime that minimizes the overhead of style injection. It ensures that styles are only applied when necessary, improving rendering speed.

  • styled-system:

    Styled-System is designed for performance, allowing developers to create responsive styles without sacrificing speed. Its focus on design tokens and utility functions helps maintain efficient rendering.

Community and Ecosystem

  • polished:

    Polished is a smaller library with a focused purpose, but it integrates well with popular CSS-in-JS libraries. Its community is supportive, though not as large as others.

  • styled-components:

    Styled-Components boasts a large and active community, with extensive documentation and a wealth of resources available. Its popularity ensures ongoing support and frequent updates.

  • emotion:

    Emotion has a growing community and is widely adopted in the React ecosystem. It benefits from a rich set of plugins and integrations, making it a versatile choice for modern applications.

  • styled-system:

    Styled-System has a dedicated community that focuses on building design systems. It is well-documented and integrates seamlessly with other libraries, making it a valuable tool for developers.

How to Choose: polished vs styled-components vs emotion vs styled-system
  • polished:

    Choose Polished if you are looking for a utility-first approach to styling that enhances your existing CSS-in-JS solution with a set of helpful functions for common CSS tasks. It is great for projects that need to simplify complex styles and improve code reusability.

  • styled-components:

    Choose Styled-Components if you prefer a robust solution with a strong emphasis on component-based styling and theming. It is well-suited for larger applications where maintaining a consistent design system is crucial.

  • emotion:

    Choose Emotion if you need a highly performant library that supports both styled components and CSS prop syntax, allowing for flexibility in how styles are applied. It is ideal for projects that require dynamic styling based on props or state.

  • styled-system:

    Choose Styled-System if you want to build a design system with a focus on responsive design and theming. It allows for rapid development of UI components that adapt to different screen sizes and design tokens.

README for polished
polished

A lightweight toolset for writing styles in JavaScript. ✨

Node CI Test codecov Github All Releases

npm install --save polished
# or if you're using yarn
yarn add polished

Want to write styles in JavaScript, but also want Sass-style helper functions and mixins? Need a consistent color palette throughout your app? ✨ polished is for you!

  • Make your app look great without stress
  • Cross framework compatible: No matter if you're using styled-components, emotion, jss, aphrodite, radium, or plain inline styles, as long as you're writing your styles in JavaScript you can use polished!
  • Switching from a pre-processor to styles in JS made easy

Docs

See the full documentation at polished.js.org!

Usage

✨ polished modules are meant to be used as stand-alone imports. You should avoid importing the entire library directly:

import { clearFix, animation } from 'polished' ~import * as polished from 'polished~ ~import polished from 'polished'~

When ✨ polished modules are imported properly, tree shaking in webpack and Rollup can be leveraged to reduce your bundle size.

Browser Support

All Evergreen Browsers + IE11

As of v3.6.X we support >0.5%, not dead, ie >= 11, not op_mini all for all our builds.

Flow Type Definitions

✨ polished has first-class Flow support with zero configuration to assist you in finding type errors while using our modules.

Ignore ✨ polished source

Flow frequently updates and it is possible that the version you are running may cause you to run into errors coming from the polished package in your node_modules directory. You can add the following lines to your .flowconfig to ignore polished in those cases:

[ignore]
.*/node_modules/polished/.*

TypeScript Definitions

✨ polished has TypeScript definitions to allow the library to be used in any TypeScript project. You will need to set moduleResolution to node in your tsconfig.json in order to use ✨ polished with TypeScript.

Babel plugin

You can optionally also use babel-plugin-polished to compile the static function calls out and remove the (already tiny) runtime performance impact of using ✨ polished.

Object Spread Properties

In the documentation you will see examples using object spread properties ({ ...other }). To enable this syntax in your project add the transform-object-rest-spread plugin (or the stage-3 preset to enable all stage three features) to your Babel configuration.

Why?

When writing styles in JavaScript, many people need Sass-style helper functions to be productive. ✨ polished brings them to you in a nice, lightweight package tailor-made for styles in JavaScript.

The main difference with Sass is that it's written in a functional style and all color functions are curried. This means you can compose them together into your own reusable helpers with a compose function of your choice:

import { compose } from 'ramda' // Replace with any compose() function of your choice
import { lighten, desaturate } from 'polished'

// Create tone() helper
const tone = compose(lighten(0.1), desaturate(0.1))

Why not package-xyz?

First of all, we didn't find another library that had everything we needed, and we don't care about installing a dozen packages separately.

Specifically most other packages that provide color functions do so in an object-oriented style, often with a fluent API that's very different from the Sass-style helpers. This means people that aren't very familiar with JavaScript might shy away from using them.

✨ polished was made as a standard library for everybody, no matter if they know JS inside out or not.

Compatibility

✨ polished is compatible with any library that accepts styles as JS objects. This includes, but is by far not limited to, styled-components, radium, aphrodite, glamor, glamorous, jss and many more!

No matter if you're using inline styles or CSS-in-JS, polished is for you.

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

Copyright © 2016-2021 Brian Hough, Maximilian Stoiber, & Nik Graf. Licensed under the MIT License, see LICENSE.md for more information!