styled-components vs jss vs emotion vs styled-system vs react-with-styles vs react-jss vs aphrodite vs react-css-modules
CSS-in-JS Libraries Comparison
1 Year
styled-componentsjssemotionstyled-systemreact-with-stylesreact-jssaphroditereact-css-modulesSimilar Packages:
What's CSS-in-JS Libraries?

CSS-in-JS libraries allow developers to write CSS directly within JavaScript files, enabling dynamic styling based on component state and props. These libraries provide a way to scope styles to components, leading to better maintainability and avoiding global CSS conflicts. They often come with features like theming, server-side rendering support, and performance optimizations, making them suitable for modern web applications that require a component-based architecture.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
styled-components7,234,64040,8451.77 MB321a month agoMIT
jss2,528,9397,091470 kB2212 years agoMIT
emotion967,799---5 years agoMIT
styled-system726,779---5 years agoMIT
react-with-styles573,8231,702-324 years agoMIT
react-jss324,0077,091811 kB2212 years agoMIT
aphrodite225,9285,341-926 years agoMIT
react-css-modules23,6755,189-506 years agoBSD-3-Clause
Feature Comparison: styled-components vs jss vs emotion vs styled-system vs react-with-styles vs react-jss vs aphrodite vs react-css-modules

Dynamic Styling

  • styled-components:

    styled-components provides a straightforward way to create dynamic styles based on props, allowing for a highly interactive and responsive design directly within the component definition.

  • jss:

    JSS enables dynamic styling via JavaScript objects, allowing for styles to be computed at runtime based on component state, which is beneficial for creating highly interactive UIs.

  • emotion:

    Emotion supports dynamic styling through its powerful API, allowing developers to create styles that can adapt based on props, making it easy to implement themes and responsive designs.

  • styled-system:

    styled-system allows for dynamic styling through its utility functions, enabling responsive design and theming based on props, which is ideal for building scalable design systems.

  • react-with-styles:

    react-with-styles abstracts styling logic and allows for dynamic styles based on the current theme or styling solution, making it flexible for various styling approaches.

  • react-jss:

    react-jss offers dynamic styling capabilities by allowing styles to be defined as functions that can accept props, enabling responsive and state-based styling directly within components.

  • aphrodite:

    Aphrodite allows for dynamic styling by using JavaScript objects to define styles, enabling styles to change based on component state or props, which is particularly useful for interactive components.

  • react-css-modules:

    react-css-modules does not inherently support dynamic styling as it relies on traditional CSS files, but it allows for scoped styles that can be conditionally applied using className manipulation.

Theming Support

  • styled-components:

    styled-components offers powerful theming capabilities, allowing developers to define theme objects that can be accessed in styled components, facilitating consistent styling across the application.

  • jss:

    JSS supports theming through its theming capabilities, allowing styles to be defined based on a theme object, which can be dynamically changed at runtime.

  • emotion:

    Emotion has excellent theming support, allowing developers to create theme objects that can be easily accessed throughout the application, making it easy to implement consistent designs.

  • styled-system:

    styled-system is designed with theming in mind, allowing developers to create responsive and theme-based styles easily, making it ideal for building design systems.

  • react-with-styles:

    react-with-styles allows for theming by abstracting the styling approach, enabling easy integration with various theming solutions, making it flexible for different design needs.

  • react-jss:

    react-jss provides robust theming support, enabling developers to create theme objects that can be used to style components consistently across the application.

  • aphrodite:

    Aphrodite does not provide built-in theming support, but theming can be implemented manually by defining styles based on a theme object.

  • react-css-modules:

    react-css-modules does not offer built-in theming support, as it relies on traditional CSS files, but theming can be achieved through CSS variables or class manipulation.

Performance Optimization

  • styled-components:

    styled-components optimizes performance through static extraction of styles, which reduces the amount of CSS injected at runtime, leading to faster render times and improved performance.

  • jss:

    JSS provides performance optimizations through its ability to generate stylesheets on the fly and supports plugins that can enhance performance further, making it suitable for large applications.

  • emotion:

    Emotion is highly performant, using a combination of static extraction and runtime injection to ensure that styles are only applied when necessary, reducing the overall CSS footprint.

  • styled-system:

    styled-system focuses on performance by minimizing the CSS output and providing utility functions that help create responsive styles without bloating the CSS.

  • react-with-styles:

    react-with-styles optimizes performance by allowing for different styling solutions to be used interchangeably, ensuring that the best-performing solution can be chosen based on the project needs.

  • react-jss:

    react-jss is optimized for performance by generating styles at runtime and supports server-side rendering, which can improve initial load times and overall performance.

  • aphrodite:

    Aphrodite focuses on performance by generating optimized stylesheets and minimizing the amount of CSS injected into the DOM, which can lead to faster rendering times.

  • react-css-modules:

    react-css-modules relies on traditional CSS, which can lead to larger file sizes, but it optimizes class name generation to avoid conflicts, ensuring better performance in scoped styles.

Learning Curve

  • styled-components:

    styled-components has a relatively easy learning curve, especially for those familiar with CSS, as it allows for writing styles in a familiar syntax within JavaScript.

  • jss:

    JSS has a moderate learning curve, particularly for developers unfamiliar with JavaScript-based styling, but its modular approach can be beneficial for maintainability.

  • emotion:

    Emotion has a moderate learning curve due to its dual API (styled components and CSS-in-JS), but it is well-documented and easy to grasp for those with CSS experience.

  • styled-system:

    styled-system may have a steeper learning curve due to its utility-first approach, but it provides powerful tools for responsive design and theming, making it worthwhile for larger projects.

  • react-with-styles:

    react-with-styles has a low learning curve, as it abstracts away the styling approach, allowing developers to focus on building components without worrying about the underlying styling solution.

  • react-jss:

    react-jss has a moderate learning curve, especially for those new to JSS, but it provides a familiar API for React developers, making it easier to adopt.

  • aphrodite:

    Aphrodite has a relatively low learning curve, making it easy for developers to start using it quickly, especially those familiar with JavaScript objects.

  • react-css-modules:

    react-css-modules is easy to learn for those already familiar with CSS, as it allows for traditional CSS usage while providing scoped styles.

How to Choose: styled-components vs jss vs emotion vs styled-system vs react-with-styles vs react-jss vs aphrodite vs react-css-modules
  • styled-components:

    Opt for styled-components if you appreciate a syntax that closely resembles traditional CSS, along with powerful theming capabilities. It is ideal for projects that require dynamic styling based on props and state, and it has a large community and ecosystem.

  • jss:

    Opt for JSS if you need a highly customizable styling solution that supports advanced features like plugins and theming. JSS is particularly beneficial for projects that require a strong focus on performance and maintainability with a modular approach.

  • emotion:

    Select Emotion for its powerful styling capabilities, including the ability to use both styled components and CSS-in-JS. It offers excellent theming support and is highly performant, making it suitable for large applications that need flexibility in styling.

  • styled-system:

    Choose styled-system if you want a utility-first approach to styling that emphasizes responsive design and theming. It is particularly beneficial for applications that need to maintain consistent design systems across components.

  • react-with-styles:

    Select react-with-styles if you need a library that abstracts away the styling approach, allowing you to switch between different styling solutions easily. This is useful for projects that may evolve in their styling needs over time.

  • react-jss:

    Choose react-jss for a seamless integration of JSS with React. It provides a simple API for styling components and supports server-side rendering, making it a good choice for applications that require both performance and SSR capabilities.

  • aphrodite:

    Choose Aphrodite if you prefer a library that focuses on performance and simplicity, allowing you to write CSS in JavaScript while generating optimized stylesheets. It is particularly useful for projects that require minimal setup and a straightforward API.

  • react-css-modules:

    Use react-css-modules if you want to leverage traditional CSS files while maintaining a modular approach. This library allows you to write CSS in separate files and automatically scopes styles to components, making it ideal for teams transitioning from CSS to CSS-in-JS.

README for styled-components

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅

downloads: 600k/month Discord gzip size module formats: umd, cjs, esm Code Coverage

Upgrading from v5? See the migration guide.

Utilizing tagged template literals (a recent addition to JavaScript) and the power of CSS, styled-components allow you to write actual CSS code to style your components. It also removes the mapping between components and styles – using components as a low-level styling construct could not be easier!

const Button = styled.button`
  color: grey;
`;

Alternatively, you may use style objects. This allows for easy porting of CSS from inline styles, while still supporting the more advanced styled-components capabilities like component selectors and media queries.

const Button = styled.button({
  color: 'grey',
});

Equivalent to:

const Button = styled.button`
  color: grey;
`;

styled-components is compatible with both React (for web) and React Native – meaning it's the perfect choice even for truly universal apps! See the documentation about React Native for more information.

Supported by Front End Center. Thank you for making this possible!


Docs

See the documentation at styled-components.com/docs for more information about using styled-components!

Quicklinks to some of the most-visited pages:


Example

import React from 'react';

import styled from 'styled-components';

// Create a <Title> react component that renders an <h1> which is
// centered, palevioletred and sized at 1.5em
const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
`;

// Create a <Wrapper> react component that renders a <section> with
// some padding and a papayawhip background
const Wrapper = styled.section`
  padding: 4em;
  background: papayawhip;
`;

function MyUI() {
  return (
    // Use them like any other React component – except they're styled!
    <Wrapper>
      <Title>Hello World, this is my first styled component!</Title>
    </Wrapper>
  );
}

This is what you'll see in your browser:


Looking for v5?

The main branch is for the most-current version of styled-components, currently v6. For changes targeting v5, please point your PRs at the legacy-v5 branch.


Built with styled-components

A lot of hard work goes into community libraries, projects, and guides. A lot of them make it easier to get started or help you with your next project! There are also a whole lot of interesting apps and sites that people have built using styled-components.

Make sure to head over to awesome-styled-components to see them all! And please contribute and add your own work to the list so others can find it.


Contributing

If you want to contribute to styled-components please see our contributing and community guidelines, they'll help you get set up locally and explain the whole process.

Please also note that all repositories under the styled-components organization follow our Code of Conduct, make sure to review and follow it.


Badge

Let everyone know you're using styled-componentsstyle: styled-components

[![style: styled-components](https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg?colorB=daa357&colorA=db748e)](https://github.com/styled-components/styled-components)

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

Licensed under the MIT License, Copyright © 2016-present Glen Maddern and Maximilian Stoiber.

See LICENSE for more information.


Acknowledgements

This project builds on a long line of earlier work by clever folks all around the world. We'd like to thank Charlie Somerville, Nik Graf, Sunil Pai, Michael Chan, Andrey Popp, Jed Watson & Andrey Sitnik who contributed ideas, code or inspiration.

Special thanks to @okonet for the fantastic logo.