liveBook · Manning

CSS-in-JS

CSS-in-JS is a styling technique that defines, composes, or generates CSS styles from JavaScript or TypeScript code.

How 3 Manning books explain it

Acing the Frontend Interview

CSS-in-JS is a styling technique that defines CSS rules within JavaScript or TypeScript code.

How it is used
Frames CSS-in-JS as a React styling choice evaluated against project requirements and competing approaches.
How deep it goes
Defines CSS-in-JS through Emotion and compares scoping, dynamic styling, theming, server-side rendering, and project fit.
Examples
Uses an Emotion-styled IconButton in BlogPostApp and contrasts equivalent styling with CSS Modules and Tailwind CSS.
What you can do after
Evaluate CSS-in-JS by matching scoping, dynamic styling, theming, rendering, and team preferences to project goals.

Read how Acing the Frontend Interview explains CSS-in-JS →

React in Depth

CSS-in-JS is a technique for defining, composing, or generating CSS styles from JavaScript code.

How it is used
Keeps React component styles closer to markup and logic when separate CSS creates coordination problems.
How deep it goes
Explains the motivation and compares styling approaches and failure modes, without showing a CSS-in-JS implementation in the supplied excerpts.
Examples
Uses a Button.js/button.css mismatch, a .group class collision, and a JavaScript width value to illustrate styling friction.
What you can do after
Evaluate/understand it when choosing among plain CSS, CSS Modules, and styled-components for a React project.

Read how React in Depth explains CSS-in-JS →

CSS in Depth, Second Edition

CSS-in-JS is a styling technique that uses JavaScript to define styles and generate or manage CSS class names.

How it is used
Addresses class-name conflicts and naming rigor in large modular CSS projects, particularly single-page applications.
How deep it goes
Defines automatic class-name generation and explains tradeoffs, but stops short of implementation details or code.
Examples
Names Styled Components, vanilla-extract, and CSS Modules as representative implementations.
What you can do after
Evaluate whether automated class-name generation suits a framework-rendered application and its toolset constraints.

Read how CSS in Depth, Second Edition explains CSS-in-JS →

Related concepts

Questions about CSS-in-JS

What is CSS-in-JS?

CSS-in-JS is a styling technique that defines, composes, or generates CSS styles from JavaScript or TypeScript code.

Which Manning books explain CSS-in-JS?

Acing the Frontend Interview, React in Depth and CSS in Depth, Second Edition.

What is the difference between CSS-in-JS and class names approach?

CSS-in-JS is a styling technique that defines, composes, or generates CSS styles from JavaScript or TypeScript code. The class names approach is a styling technique that associates markup elements with CSS rules through named classes.

What kinds of CSS-in-JS are there?

Kinds of CSS-in-JS include styled-components.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.