Skip to main content
← 🎨 CSS as a design systemΒ·Module B8 Β· Lesson 9
TaskRead the theory above. Then build a single styled button in plain CSS (no CSS-in-JS): .button { padding: 8px 16px; background: #3B82F6; color: white; border-radius: 8px; border: none; cursor: pointer; }.

CSS-in-JS: the case against (for a Python dev)

75 XP6 min
Theory

What is CSS-in-JS

Libraries like styled-components, Emotion, Stitches:

const Button = styled.button`
  background: ${props => props.primary ? "#3B82F6" : "#e5e7eb"};
  color: white;
  padding: 8px 16px;
`;

Styles live inside JS, generated at runtime, injected into a <style> tag.

Why this got popular (2016-2020)

  • CSS modules + Sass were verbose.
  • Themes were hard to wire up.
  • Dynamic styles (based on props) needed JS anyway.
  • Tooling was JS-heavy already.

Why it's losing in 2026

  1. Runtime cost. Every render parses + serializes styles. Real perf hit.
  2. Larger bundles. Library + your styles + theme tokens ship together.
  3. Hydration cost. Styles initialize AFTER React boots β€” flicker.
  4. Native CSS caught up. @scope + @layer + custom properties + nesting do everything styled-components did, natively.
  5. Tailwind exists. For dynamic-style use cases, Tailwind's class composition + JS conditionals is faster.

The 2026 answer

For a backend dev who just wants a UI:

  • Don't reach for styled-components.
  • Do use plain CSS files OR Tailwind.

CSS in a .css file is faster, easier to debug, and produces smaller bundles. The "ergonomic" arguments for CSS-in-JS evaporated when native CSS shipped scoping, nesting, and custom properties.

When CSS-in-JS still makes sense

  • Existing codebases (don't rewrite a working styled-components app).
  • Component libraries that need to ship "themeable" components (Radix, Mantine).
  • Pages with truly per-user, runtime-computed styles.

For 95% of "I just need a UI on my Python backend" β€” plain CSS or Tailwind wins.

This lesson is theory-only β€” no code task. Read, understand, move on.

πŸ”’

Sign up to start coding

Theory is open to everyone. The interactive editor, live preview, and check are unlocked with a 7-day free trial β€” card required, cancel anytime.

Sign up β€” free trial β†’

First 10 lessons in each track are free. No card needed for those.

← PreviousNext lesson β†’

Get one Python or web tip a day β€” by email

Short, hand-written, no spam. Unsubscribe in one click.