Emotion's Two APIs: styled and css Prop
You'll learn when to choose Emotion's styled API versus the css prop for styling your components.
Two Paths to the Same Goal
Emotion gives you two distinct ways to style components, much like having both a paintbrush and a spray can—both apply color, but each excels in different situations.
The styled API: Component-Based Styling
Similar to styled-components, styled.div creates a new styled component:
import styled from '@emotion/styled';
const Button = styled.button`
padding: 12px 24px;
background: ${props => props.primary ? 'blue' : 'gray'};
color: white;
`;
// Usage
<Button primary>Click me</Button>
Use styled when you're creating reusable, named components with consistent styling logic that might be used across your app.
The css Prop: Inline Styling Power
The css prop applies styles directly to any element without creating a wrapper component:
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
const buttonStyle = css`
padding: 12px 24px;
background: blue;
color: white;
`;
// Usage
<button css={buttonStyle}>Click me</button>
Use the css prop for one-off styles or when you want styling logic close to where it's applied without the overhead of defining a new component.
When to Choose Which
styled: Building a component library, creating semantic components (PrimaryButton,Card), or when the component will be reusedcssprop: Quick styling adjustments, local variations, or prototyping without commitment to a component abstraction
Both compile to the same efficient output, so the choice is about developer experience and code organization rather than performance.
Key Takeaway: Emotion's styled API creates reusable component abstractions, while the css prop applies styles directly—choose based on whether you're building a component or styling an instance.