Emotion is a CSS-in-JS library. It lets you write real CSS — the same selectors, media queries, and pseudo-classes you already know — but inside your JavaScript files, scoped to a component. If you like CSS but hate managing class names and global stylesheets, Emotion is the middle ground.
There are two ways to use it. The css prop lets you style any element inline:
/** @jsxImportSource @emotion/react */ import { css } from "@emotion/react"; function Card() { return ( <div css={css` padding: 24px; border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); &:hover { transform: translateY(-2px); } `} > Hover me </div> ); } Or use styled to create reusable components that look like normal HTML tags:
import styled from "@emotion/styled"; const Button = styled.button` padding: 10px 20px; background: ${(props) => (props.primary ? "#0070f3" : "#eee")}; color: ${(props) => (props.primary ? "#fff" : "#333")}; border: none; border-radius: 8px; cursor: pointer; `; <Button primary>Click me</Button> Props flow into your styles, so variants like primary and secondary buttons stay in one place. Theming works the same way — define colors once, use them everywhere with props.theme.
Who is it for? Developers who know CSS well and want it colocated with their components. It is a good fit for design systems, component libraries, and any project where styles need to change based on props or state.
The limits: styles live in JavaScript, so there is a runtime cost — the browser builds styles as your app runs. Very large apps sometimes prefer zero-runtime tools instead. And if your team dislikes CSS-in-JS on principle, Emotion will not change their mind.
Start today: pick one component in an existing React project and rewrite its stylesheet with Emotion's styled. Compare the two versions side by side — you will quickly feel whether colocated CSS suits you.
