Tailwind CSS interview question · Most asked
How does Tailwind decide which CSS to generate?
Summary
It scans your source files as plain text for anything that looks like a class name and generates CSS only for those, so the output contains just what you use. In v4 detection is automatic (respecting .gitignore); you add paths with @source and safelist strings with @source inline().
Longer Answer
Because the scan is textual, class names must appear in full in source code; strings built from fragments at runtime aren't detected.
Key Points
- Text scan of sources.
- Only used classes generated.
- @source to add or exclude paths.
- Write class names in full.
Deep dive: Tailwind CSS in Production: The Badge That Lost Its Colour
Explanation
What interviewers look for
The textual-scan consequence.
More most-asked Tailwind CSS questions
- Why doesn't className={`bg-${color}-500`} work, and what should you do instead?
- Explain Tailwind's responsive design approach.
- How do you customize Tailwind's design tokens in v4?
- What is Tailwind CSS and what does 'utility-first' mean?
- How do you implement dark mode with Tailwind?
- How do you avoid repeating long class lists?
- What changed in Tailwind CSS v4 compared with v3?
- How do you make Tailwind interfaces accessible?