Course contentsShow
← React
Lesson 1955 of 2,39644. Styling ApproachesFree lesson

When Runtime CSS-in-JS Still Makes Sense

Specific use cases where styled-components or Emotion remain the right choice despite trade-offs.

When Runtime CSS-in-JS Still Makes Sense

What you'll learn: Despite the industry shift toward zero-runtime solutions, there are specific scenarios where styled-components or Emotion remain the optimal choice.

The Context

You've seen the reasons against runtime CSS-in-JS: performance overhead, incompatibility with Server Components, larger bundle sizes. The ecosystem has moved toward Tailwind, CSS Modules, and vanilla-extract. But runtime CSS-in-JS isn't obsolete—it excels in particular use cases.

Where Runtime Still Wins

Highly dynamic, user-driven styling. When users control colors, sizes, spacing, or layout properties through interactive tools (theme builders, design editors, dashboards), runtime CSS-in-JS shines. These values can't be pre-generated at build time because they're truly dynamic—unknown until the user acts.

Component libraries with maximum flexibility. If you're building a published component library where consumers need extreme customization without touching your source code, runtime CSS-in-JS provides the most ergonomic API. Props become styles naturally, and consumers don't need build-tool configuration.

Prototyping and small applications. The developer experience advantage is real. For MVPs, internal tools, or projects where time-to-market matters more than milliseconds of performance, the friction of setup is minimal and the colocation benefits are maximal.

Client-only applications. If you're not doing SSR or using Server Components—think admin panels, electron apps, or SPAs—many downsides disappear. No hydration mismatches, no server incompatibility.

The Honest Assessment

Think of runtime CSS-in-JS like a Swiss Army knife: heavier than a specialized tool, but unmatched for flexibility. For most production apps pursuing optimal performance, zero-runtime solutions win. But when your styling needs are genuinely unpredictable at build time, runtime CSS-in-JS remains the pragmatic choice.

Key Takeaway: Runtime CSS-in-JS makes sense when styles are truly dynamic (user-controlled values), when shipping a flexible component library, or when developer experience outweighs performance concerns in client-only contexts.