Skip to content

Top 30 Tailwind CSS Interview Questions and Answers [2026]

October 14, 2026 12 min read
Tailwind CSS interview guide by Second Talent
TL;DR: Tailwind CSS interviews in 2026 test whether a candidate knows v4: configuration in CSS with @theme, @utility and @custom-variant instead of tailwind.config.js, automatic source detection, and the renamed v3 utilities. The current release is Tailwind CSS 4.3.3, from July 16, 2026.

Tailwind CSS v4.0 shipped on January 22, 2025 with no tailwind.config.js by default: one line, @import "tailwindcss";, replaces the three @tailwind directives, and the theme lives in CSS.

Candidates who learned Tailwind before 2025 still write darkMode: 'class' and bg-opacity-50, and neither does anything in v4. Every CSS answer below was compiled with Tailwind 4.3.3 to confirm the output.

Key takeaways
  1. 1v4 needs Safari 16.4, Chrome 111 and Firefox 128 or newer. Projects that must support older browsers stay on v3.4, which still gets patch releases.
  2. 2In Tailwind's own benchmark, an incremental rebuild with no new CSS fell from 35 ms in v3.4 to 192 microseconds in v4.0.
  3. 3The plain ring utility went from 3px to 1px, and borders default to currentColor instead of gray-200.
  4. 4v4 is not designed to work with Sass, Less or Stylus; Tailwind now handles imports and vendor prefixes itself.

Fundamentals

1. What is utility-first CSS, and what problem does Tailwind solve?

Utility-first means styling elements with small single-purpose classes such as flex, p-4 and text-sm in the markup, instead of writing a new CSS class for each component.

Tailwind generates those classes from a design system of spacing, color and type scales.

The problems it removes are naming things, CSS files that only grow because nobody knows whether a rule is still used, and styles that drift from the design scale.

The costs are long class attributes and a learning curve for the class names. A strong candidate names both sides and says the long class lists belong inside components, where they are written once.

2. How does Tailwind know which CSS to generate?

It scans your project's files as plain text for anything that looks like a class name, then generates CSS only for the tokens that match a utility or variant.

In v4 this happens with no configuration: per the source detection docs, Tailwind scans every file except those in .gitignore, node_modules, binary files, CSS files and lock files.

Four steps of a Tailwind v4 build: @import tailwindcss loads the layers, source files are scanned as plain text skipping gitignored files and node_modules, only complete class names match, and only matched utilities are generated.

The output only contains classes that appear somewhere in source, so a production stylesheet stays small no matter how many utilities exist. The v3 content array is gone; @source (question 14) covers the cases automatic detection misses.

Where scanning starts. Tailwind scans from the current working directory. In a monorepo where the build runs from the root, @import "tailwindcss" source("../src"); sets the base path explicitly.

3. Why does bg-${color}-600 not work, and what do you do instead?

Because the scanner reads text, not JavaScript. The string bg-red-600 never appears in the file, so the class is never generated. The fix is to keep complete class names in source and pick between them:

<script>
  const colors = {
    danger: "bg-red-600 hover:bg-red-500",
    success: "bg-green-600 hover:bg-green-500",
  };
  button.className = colors[variant];
</script>

The bug is easy to miss: if bg-red-600 happens to appear somewhere else in the project, the class is generated and the component looks right, until someone deletes that other usage.

A candidate who has been bitten by it explains it in one sentence.

4. How do responsive breakpoints work?

Breakpoints are mobile-first min-width queries: an unprefixed utility applies at every size, and md: applies from the md width up. max-* variants target below a breakpoint, and stacking them targets a range.

<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
  <p class="hidden md:max-lg:block">Only between md and lg</p>
  <p class="max-sm:text-sm">Smaller text under sm</p>
</div>

The defaults are sm 40rem, md 48rem, lg 64rem, xl 80rem and 2xl 96rem, per the responsive design docs. The mistake to listen for is using sm: to mean "on phones": it means "from 40rem up".

5. How do you style an element based on a parent's or sibling's state?

Mark the parent with group and use group-hover: on the child; mark a previous sibling with peer and use peer-invalid:, peer-checked: and so on. ARIA and data attributes have their own variants.

<a class="group block rounded-lg p-4 hover:bg-gray-50">
  <h3 class="font-medium group-hover:underline">Plan</h3>
</a>

<input type="email" class="peer border" />
<p class="invisible peer-invalid:visible">Enter a valid email.</p>

<button aria-expanded="false" class="aria-expanded:rotate-180"></button>
<div data-state="open" class="data-[state=open]:bg-white"></div>

peer only works on later siblings, because CSS's ~ combinator only looks forward. In v4, hover: is wrapped in @media (hover: hover), so it no longer fires on tap on touch screens.

6. When do you use arbitrary values, and what changed in their syntax?

Square brackets take any value the scale does not have, such as top-[117px]; [property:value] sets a property Tailwind has no utility for. In v4, a CSS variable goes in parentheses, bg-(--brand-color), where v3 used bg-[--brand-color].

<div class="top-[117px] bg-(--brand-color) grid-cols-[max-content_auto] lg:[mask-type:luminance]"></div>

Underscores stand for spaces, and v4 dropped the v3 habit of turning commas into spaces in grid-cols-[...], so grid-cols-[max-content,auto] must become max-content_auto.

More than a few arbitrary values of the same kind is a sign the value belongs in @theme.

7. A component takes a class prop. How do you let callers override its padding?

Not by putting the caller's class last. The order of names in the class attribute does not matter; the order of rules in the generated stylesheet does, so p-4 p-2 gives whichever rule Tailwind emitted later.

The standard fix is tailwind-merge, which removes the conflicting class before rendering; its v3 line supports Tailwind 4.0 to 4.3.

The v4 alternative for a single forced override is the important modifier at the end of the class, p-2!. A candidate who designs components with variant props instead of free-form overrides avoids most of these conflicts.

Configuring v4 in CSS

8. How do you customize the theme in v4 without tailwind.config.js?

With theme variables in an @theme block in your main CSS file. Each variable both defines a design token and creates the utilities for it: --color-brand-500 gives you bg-brand-500, text-brand-500 and every other color utility.

@import "tailwindcss";

@theme {
  --color-brand-500: oklch(0.64 0.19 45);
  --font-display: "Satoshi", sans-serif;
  --breakpoint-3xl: 120rem;
}

That file makes bg-brand-500, font-display and a 3xl: breakpoint at 120rem available; we compiled it and all three appeared in the output. The theme docs list the namespaces (--color-*, --font-*, --breakpoint-*, --spacing and more).

Every token is also a real CSS variable on :root, so JavaScript and inline styles can read it.

9. What is the difference between @theme and @theme inline?

Both create utilities. With @theme, the utility points at the theme variable; with @theme inline, the utility gets the variable's value written in. It matters when a token refers to another variable.

@theme {
  --font-body: var(--font-inter);
}

@theme inline {
  --font-heading: var(--font-inter);
}

Compiled, font-body becomes font-family: var(--font-body), while font-heading becomes font-family: var(--font-inter).

Without inline, var(--font-inter) is resolved where --font-body is defined, on :root, so a new value of --font-inter set on a lower element never reaches the utility. inline fixes that.

10. How do you add a custom utility in v4?

With @utility. v4 uses native cascade layers and no longer turns classes in @layer utilities into utilities that work with variants, so @utility replaces that pattern.

@utility content-auto {
  content-visibility: auto;
}

@utility stack-* {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing) * --value(integer, --default(4)));
}

The second one is a functional utility: --value(integer) reads the number from the class name, so stack-2 compiles to gap: calc(var(--spacing) * 2). The --default(4) argument, added in v4.3, makes a bare stack work too; we compiled both.

Custom utilities work with every variant, so md:stack-6 needs nothing extra.

11. How do you add your own variant?

With @custom-variant, giving it a selector or at-rule. This one styles elements inside a data-theme="midnight" container:

@custom-variant midnight (&:where([data-theme="midnight"], [data-theme="midnight"] *));

After that, midnight:text-white works like any built-in variant. Using :where() keeps the added selector at zero specificity, so the variant does not beat an unrelated utility by accident.

12. How do you switch dark mode with a class instead of the OS setting?

Override the dark variant in CSS. By default, dark: follows prefers-color-scheme; the v3 darkMode: 'class' config key does nothing in a v4 CSS setup.

@custom-variant dark (&:where(.dark, .dark *));

dark:bg-gray-900 then compiles to .dark\:bg-gray-900:where(.dark, .dark *), which applies whenever an ancestor has the dark class.

The dark mode docs show the data-attribute version and the few lines of JavaScript that set the class before first paint, which is what prevents a flash of the light theme.

13. Why does @apply fail inside a Vue or Svelte style block, and how do you fix it?

In v4, stylesheets that are bundled separately from your main CSS, such as Vue, Svelte and Astro style blocks and CSS modules, do not see your theme, custom utilities or custom variants. @reference imports them for lookup only, without copying any CSS into the output.

@reference "./app.css";

h1 {
  @apply font-display text-2xl text-brand-500;
}

We compiled that block on its own: the output is the single h1 rule, with no Preflight or utilities duplicated.

The upgrade guide also suggests the simpler route of reading theme variables directly, as in color: var(--color-brand-500), which skips @apply altogether.

14. How do you include classes the scanner cannot see, or exclude a folder?

Use @source to add a path, @source not to exclude one, and @source inline() to force classes into the build, which replaces v3's safelist. Brace expansion keeps the list short.

@source "../node_modules/@acme/ui/dist";
@source not "./legacy";
@source inline("{hover:,}bg-red-{50,{100..300..100}}");

The inline rule generated bg-red-50, bg-red-100 to bg-red-300 and their hover: versions. The excluded legacy folder's classes did not appear.

The first line is the common case: a UI library in node_modules, which v4 ignores by default. @source not and @source inline() arrived in v4.1.

15. Can you still use a JavaScript config or a v3 plugin?

Yes, explicitly. JavaScript config files are no longer detected automatically; load one with @config "./tailwind.config.js"; and a plugin with @plugin "@tailwindcss/typography";.

The corePlugins, safelist and separator options are not supported, and resolveConfig was removed. A candidate who proposes keeping the JS config forever has missed that the CSS variables v4 generates are what replaced it.

Layout and Components

16. How do container queries work in v4?

They are built in, where v3 needed a plugin. Mark an element as a container with @container, then use @sm:, @md: and the other sizes on its descendants, or @max-* for below a size. Name containers to target an outer one.

<div class="@container">
  <div class="flex flex-col @md:flex-row @max-xs:text-sm">
    <!-- lays out by the card's width, not the viewport's -->
  </div>
</div>

<aside class="@container/sidebar">
  <nav class="@lg/sidebar:grid-cols-2 grid"></nav>
</aside>

The answer interviewers want is when to use them: a card that appears in a wide main column and a narrow sidebar should respond to its own width, which a viewport breakpoint cannot see. v4.3 added @container-size for containers that also query height.

17. How do you style a card when the radio button inside it is checked?

With the has-* variant, which compiles to the CSS :has() pseudo-class. No JavaScript and no peer ordering tricks.

<label class="rounded-lg border p-4 has-checked:border-indigo-600 has-checked:bg-indigo-50">
  <input type="radio" name="plan" class="sr-only" />
  Pro plan
</label>

has-checked: applies when any descendant matches :checked; has-[...] takes any other selector.

Keeping the input in the label, visually hidden with sr-only, keeps it keyboard and screen-reader accessible, which is the part a weak answer skips when it swaps the input for a clickable div.

18. How do you animate a popover or dialog opening without JavaScript?

Use the starting: variant, which wraps the style in CSS @starting-style, together with transition-discrete, which lets display transition so the exit animation runs before the element disappears.

<div popover id="menu"
  class="opacity-0 transition-all transition-discrete open:opacity-100 starting:open:opacity-0">
  Menu
</div>

The element fades from 0 to 100% opacity when it opens and back when it closes. @starting-style is newer than v4's baseline browsers, so on an older browser the popover simply appears without the fade, which is an acceptable fallback here.

19. When should you extract a component instead of repeating classes?

When the same markup repeats, extract a component in your framework (a React, Vue or Blade component), not a CSS class. The classes then live in one file and the markup stays readable.

@apply is for the cases a component cannot cover, such as styling HTML from a CMS or a third-party widget.

A codebase with a .btn, .card and .input for everything built from @apply has rebuilt the CSS it moved away from, with an extra build step. In v4, a genuine custom class is written with @utility so variants work on it.

20. What accessibility utilities should a Tailwind developer reach for?

sr-only for text only screen readers should announce, focus-visible: for keyboard focus rings, motion-reduce: and motion-safe: for animation, and forced-colors: for Windows high contrast mode.

<button class="focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 motion-safe:transition motion-reduce:transition-none">
  <svg aria-hidden="true" class="size-5"></svg>
  <span class="sr-only">Close menu</span>
</button>

The trap: in v3, outline-none set an invisible outline that still showed in forced-colors mode. v4 renamed that behavior to outline-hidden and made outline-none set outline-style: none.

A candidate who removes focus outlines with outline-none and adds nothing back fails the keyboard user.

Build and Tooling

21. What changed in the v4 engine, and how much faster is it?

v4 was rewritten with a new engine, bundles @import handling and uses Lightning CSS for vendor prefixing and syntax transforms, so postcss-import and autoprefixer can go.

3.78x
Full build, 378 ms to 100 ms
8.8x
Incremental rebuild with new CSS, 44 ms to 5 ms
182x
Incremental rebuild with no new CSS, 35 ms to 192 µs
Median build times, v3.4 against v4.0, on Tailwind's Catalyst UI kit. Source: Tailwind CSS v4.0 announcement, January 22, 2025.

The last number matters most in daily work: most saves while editing only reuse classes that already exist, and those rebuilds now finish in microseconds.

22. Which integration should a project use: Vite, PostCSS, CLI or webpack?

The @tailwindcss/vite plugin for Vite-based projects (Vue, Svelte, Astro, React with Vite), @tailwindcss/postcss where a PostCSS pipeline already exists, and @tailwindcss/cli for projects with no bundler. v4.2 added @tailwindcss/webpack; the v4.3 announcement reports it over 2x faster than the PostCSS route in large webpack projects.

In v3, the tailwindcss package itself was the PostCSS plugin; in v4 it is not, which is the first error people hit when upgrading a PostCSS config by hand.

23. Which browsers does v4 support, and what if you need older ones?

Per the compatibility page, v4's core depends on Chrome 111 and Safari 16.4 (both March 2023) and Firefox 128 (July 2024), because it is built on cascade layers, @property and color-mix().

A product that must support older browsers, such as an enterprise app on locked-down machines, stays on v3.4; v3.4.19 shipped on December 10, 2025.

Asking which browsers the candidate's last project supported, and how they checked, tells you more than the version numbers.

24. Can you use Tailwind v4 with Sass?

No, not as a supported setup. The compatibility page says v4 "is not designed to be used with CSS preprocessors like Sass, Less, or Stylus", and that includes lang="scss" style blocks in Vue or Svelte.

Native CSS nesting, variables and Tailwind's own @import handling cover what most teams used Sass for. A migration plan for a Sass-heavy codebase has to budget for converting those files first.

What Changed Recently

Jan 22, 2025
v4.0: CSS-first configuration, new engine, container queries built in
Apr 1, 2025
v4.1: text shadows, masks, @source not and @source inline()
Feb 18, 2026
v4.2: logical property utilities, four new neutral palettes, webpack plugin
May 8, 2026
v4.3: scrollbar, zoom and tab utilities, default values for functional utilities
Jul 16, 2026
v4.3.3: current patch release

25. Which v3 classes look different after upgrading to v4?

The scales shifted one step so that every size has a name: v3's shadow-sm is v4's shadow-xs, and v3's bare shadow is now shadow-sm. The same applies to rounded, blur and drop-shadow.

Bare ring is 1px (use ring-3 for the old look), borders and rings default to currentColor, placeholders use the text color at 50% opacity, and buttons get cursor: default.

Table of Tailwind v3 habits and v4 replacements: @tailwind directives become @import, theme.extend becomes @theme, darkMode class becomes @custom-variant, safelist becomes @source inline, bg-opacity becomes a slash modifier, shadow-sm becomes shadow-xs, ring becomes ring-3.

None of these produce errors. The page just looks slightly off, which is why the upgrade guide is required reading. The bg-opacity-* family and flex-grow-* were removed outright; bg-black/50 and grow replace them.

26. What changed in variant order, the important modifier and prefixes?

Three syntax changes catch people who upgrade by hand:

<div class="tw:flex tw:hover:bg-red-600 bg-red-500! *:first:pt-0"></div>
  • Stacked variants read left to right, like CSS. v3's first:*:pt-0 is v4's *:first:pt-0.
  • The ! goes at the end: bg-red-500!. The v3 prefix form still works but is deprecated.
  • A prefix looks like a variant and always comes first: tw:flex, tw:hover:bg-red-600, set with @import "tailwindcss" prefix(tw);. We compiled that and both classes were generated.

27. What did Tailwind v4.1 add?

The v4.1 release of April 1, 2025 added text-shadow-* and mask-* utilities, colored drop shadows, the pointer variants (pointer-fine, pointer-coarse), user-valid and user-invalid for forms, noscript, safe alignment utilities, and @source not and @source inline().

It also made the scanner ignore node_modules by default. user-invalid: is the one to ask about: it shows an error only after the user has interacted with the field, which invalid: cannot do.

28. What did v4.2 add?

v4.2, released on February 18, 2026, filled in logical property utilities: pbs-* and pbe-* for block padding, mbs-* and mbe-* for block margin, inline-* and block-* for sizes, and inset-s-* and inset-e-*, which deprecate start-* and end-*.

It also added the mauve, olive, mist and taupe palettes, font-features-* and the webpack plugin. Logical utilities are the right default for any product that ships a right-to-left language, because they flip with the writing direction.

29. What is new in v4.3?

The v4.3 release of May 8, 2026 added scrollbar styling, zoom-*, tab-*, scrollbar-gutter-*, @container-size, stacked and compound variants in @variant, and --default() for functional utilities.

<p class="text-shadow-lg text-shadow-sky-300/50">Heading</p>
<img class="mask-b-from-60% mask-b-to-100%" src="hero.jpg" alt="" />
<ul class="h-64 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-400 scrollbar-track-transparent"></ul>
<div class="pbs-4 mbe-2 inline-80 inset-s-0 bg-mauve-50"></div>

We compiled this block on 4.3.3, and every class in it generated CSS, including the v4.1 text shadow and mask and the v4.2 logical and mauve utilities.

Before 4.3, scrollbar colors meant a plugin or hand-written CSS with vendor pseudo-elements.

30. How would you upgrade a v3 project to v4?

Run the official tool on a new branch: npx @tailwindcss/upgrade. It updates dependencies, converts the JavaScript config to CSS and rewrites renamed classes in templates. It needs Node.js 20 or newer.

Then review the diff and check pages in a browser, because the tool cannot see visual changes such as the border color default, and it cannot fix class names built with string interpolation.

A strong answer adds two checks before starting: the browser support list (question 23) and any Sass in the project (question 24), since either can block the upgrade entirely.

Signs of a Strong Answer

  • They configure in CSS with @theme and only reach for @config as a migration step.
  • They explain why interpolated class names fail by describing the scanner, not by memorizing the rule.
  • They know the v3 to v4 renames and can say which ones change a page without any error.
  • They pick container queries over breakpoints for components that live in different column widths.
  • They extract components in the framework and treat @apply as an exception.
  • They keep focus styles when removing outlines, and use motion-reduce: on anything that moves.

Hiring Tailwind Developers

Tailwind is usually one skill of a front-end developer, not a role of its own.

Second Talent matches companies with pre-vetted front-end developers in Asia who work in Tailwind with React, Vue and other frameworks; see the front-end developer cost guide for typical rates.

Tell us the stack and we send a shortlist within 24 hours. Start hiring, or see our front-end developer interview questions.

Ready to hire? Hire Front-End Developers: vetted AI-native talent, with first profiles in 24 hours.

Get developers who ship with AI agents. Starts at $25/Hour.

Start Hiring $0 cost until you hire