A CSS-in-JS library that accepts string or object styles with predictable composition to reduce specificity clashes. Packages cover framework-agnostic class names and React-focused css and styled APIs.
Overview
Emotion lets teams write component styles in JavaScript instead of separate stylesheets. It supports both string and object syntax, caches generated rules in production, and aims for predictable composition when styles are merged.
The framework-agnostic @emotion/css path uses css and cx to build class names, with nested selectors, media queries, and automatic vendor prefixes without mandatory Babel setup. Server rendering needs extra configuration on that path.
For React, @emotion/react adds a css prop, theming, and server-side rendering with minimal setup, while @emotion/styled offers a styled component API similar to other CSS-in-JS tools. An optional Babel plugin unlocks further optimizations.
Documentation covers installation, composition, nested selectors, and media queries. Demos and sandbox examples illustrate usage patterns across the ecosystem.
Key features
- String and object style objects
- Predictable style composition
- React css prop and styled API
- Framework-agnostic css package
- Source maps and debug labels
- Nested selectors and media queries
- Optional Babel optimizations
- Production style caching
Use cases
- React apps with co-located styles
- Themed component libraries
- SSR React sites with Emotion
- Vanilla JS via class names
- Design systems using styled API