CSS in React — React Technical Interview Questions & Answers

CSS in React

CSS in React

  • In React you still write CSS. Common ways: import './Card.css' + className, CSS modules (Card.module.css → styles.title), inline style objects, Tailwind utilities, CSS-in-JS. className, not class. One imported CSS file is global unless you use modules.
  • Pick one approach per project. Mixing Bootstrap grid + Tailwind + inline chaos is how UIs rot. Interview: name two methods and when you’d pick modules (avoid name clashes).
  • CSS in React — on screen: Hello inside .card styles. File import applies globally unless modules.

Technical Interview Tip: className + one styling approach.

Code Examples for CSS in React

Example

// CSS
import "./Card.css";

export default function Card() {
  return <article className="card">Hello</article>;
}

CSS in React — on screen: Hello inside .card styles. File import applies globally unless modules.

How to Explain CSS in React to an Interviewer

Explain CSS as if you are teaching a junior — definition, then one tiny UI.

className. file / modules / inline / Tailwind.

What does the example show on screen (or print), and what does that prove?

CSS in React — on screen: Hello inside

What mistake do freshers make with CSS?

global class name clashes.