emotion README

The project's README from github.com/emotion-js/emotion. As one markdown file: README.md.

Emotion logo

emotion

The Next Generation of CSS-in-JS

Emotion 11 has been released 🚀 See the blog post

Backers on Open Collective Sponsors on Open Collective npm version Build Status codecov @emotion/css size @emotion/css gzip size @emotion/react size @emotion/react gzip size @emotion/styled size @emotion/styled gzip size slack

Emotion is a performant and flexible CSS-in-JS library. Building on many other CSS-in-JS libraries, it allows you to style apps quickly with string or object styles. It has predictable composition to avoid specificity issues with CSS. With source maps and labels, Emotion has a great developer experience and great performance with heavy caching in production.

👀 Demo Sandbox

📖 Docs

Frequently viewed docs:

Quick Start

Get up and running with a single import.

npm install --save @emotion/react
/** @jsx jsx */
import { jsx } from '@emotion/react'

let SomeComponent = props => {
  return (
    <div
      css={{
        color: 'hotpink'
      }}
      {...props}
    />
  )
}

Do I Need To Use the Babel Plugin?

The babel plugin is not required, but enables some optimizations and customizations that could be beneficial for your project.

Look here 👉 emotion babel plugin feature table and documentation

Demo Sandbox

Demo Code Sandbox

Examples

Ecosystem

In the Wild

Sponsors

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

Thinkmill

Backers

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

Contributors

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

emotion (emotion-js/emotion)

Searching Database…

What is this?Emotion is a performant and flexible CSS-in-JS library for JavaScript: you write styles in your JS code instead of separate CSS files. It is one of the most popular libraries in this space.
Is this React-only, or does it work with other frameworks?It is a general JavaScript library that is best known in the React ecosystem, but the ecosystem includes adapters for Vue, Nuxt and Ember as well.
How do I add it to a project?Install the package from npm or yarn (e.g. npm install @emotion/react). Per the Quick Start you are up and running with a single import; the docs' Install page has the details.
Do I need to set up the Babel plugin for it to work?No, the Babel plugin is optional. It is not required, but it enables some optimizations and customizations, and the docs have a feature table showing exactly what you gain with it.
Why would I use this instead of plain CSS files?Styles compose predictably so you avoid CSS specificity issues, you get source maps and labels for debugging, and production builds use heavy caching for performance.
Is it production-ready, or more of an experiment?Very battle-tested: the 'In the Wild' section lists production sites like The New York Times, Sentry, Codecademy, Postmates and Apache Superset, plus component libraries built on it.
Does it work outside the browser, like in React Native apps?Yes, there is Emotion Native support in the ecosystem, including emotion-native-extended for better styling with React Native Extended Stylesheet.
How do I actually write styles with it?You can use string or object styles via the css prop or the styled API. Composition, nested selectors and media queries are all supported and documented.
Can I try it without installing anything?Yes, the README links a live CodeSandbox demo, so you can play with Emotion in the browser before adding it to a project.
Is there tooling around it, like linting?Yes, there is a stylelint integration in the ecosystem, plus helpers like facepaint and css-in-js-media for responsive design and polished for Sass-style mixins in JS.
Creator
emotion-js
Size
24.9 MB
Stars
18K
Age
9y
Commits · 90 Days