Tailwind CSS interview question · Most asked

How does Tailwind decide which CSS to generate?

Create a free account to save this page, take notes and track your progress. Sign in

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

← All Tailwind CSS questions

Was this page helpful?