🎨
UI Component8M+/wkMIT

@emotion/react

Emotion is a performant and flexible CSS-in-JS library that provides multiple APIs for styling React applications. The @emotion/react package provides the css p

Installation

npm
npm install @emotion/react @emotion/styled
yarn
yarn add @emotion/react @emotion/styled
pnpm
pnpm add @emotion/react @emotion/styled

Import

ESM
import { css } from '@emotion/react';

Quick Example

usage
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';

const style = css`
  background: #3b82f6;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
`;

function App() {
  return <button css={style}>Click me</button>;
}

About @emotion/react

Emotion is a performant and flexible CSS-in-JS library that provides multiple APIs for styling React applications. The @emotion/react package provides the css prop for inline styles (css={{ color: 'red' }} or css={css`color: red`}), while @emotion/styled provides an API similar to styled-components for creating styled React components. Emotion's key advantage is its performance — it generates styles at build time when possible through the Babel plugin, reduces runtime overhead with a highly optimized insertion mechanism, and produces smaller bundles than alternatives. The library supports dynamic styles based on props, theming through ThemeProvider, global styles, keyframe animations, media queries, pseudo selectors, and style composition through the css function. Emotion generates unique class names for style encapsulation and supports server-side rendering with zero configuration in Next.js. The library provides both string-based (template literals) and object-based style authoring. Emotion is the CSS-in-JS solution chosen by many major UI libraries — it powers Chakra UI and MUI's styling engine. While some projects are moving away from runtime CSS-in-JS toward Tailwind or CSS Modules for performance reasons, Emotion remains one of the most capable and flexible styling solutions for React applications.

Quick Facts

Package@emotion/react
CategoryUI Component
Weekly Downloads8M+
LicenseMIT
Installnpm install @emotion/react @emotion/styled

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.