/

Tailwind CSS Common Mistakes That Break Your UI

Diagnose missing Tailwind classes, mobile breakpoint errors, flex overflow, theme mismatches, and invisible focus states with practical fixes.

Serafim Korablev
Serafim Korablev
@korablev

When a Tailwind interface looks wrong, start by asking which layer failed: was the utility generated, did the intended variant activate, or did the resulting CSS fail to accommodate the content?

That distinction keeps a missing stylesheet rule from turning into a layout rewrite. This guide uses current Tailwind CSS v4 conventions and focuses on visible UI problems. If the issue started during an upgrade, consult the Tailwind v4 migration guide alongside the project's installed version.

1. Building class names from string fragments

Tailwind scans source files as text. It does not evaluate JavaScript expressions to discover the resulting class name. Consequently, an expression such as bg-${tone}-600 does not reliably supply the complete class tokens the generator needs. Map component variants to complete, statically visible classes instead. Tailwind's source-detection documentation explains this behavior.

This original, illustrative example keeps the public API small:

tsx

This is an example of class construction, not a tested production component or a complete theme implementation. If styles disappear only for a shared package, check whether Tailwind scans that package before changing its classes.

2. Treating sm: as “small screens only”

Tailwind's default breakpoint variants apply from their minimum width upward. Unprefixed utilities form the base. Therefore, sm:flex-col does not mean “stack on phones”; it starts applying at the sm breakpoint. The responsive-design docs describe the mobile-first model and configurable breakpoints.

For a layout that should stack first and become a row later, start with flex-col and add an appropriate larger-width flex-row variant. Inspect the width just below that breakpoint as well as just above it. A spacious desktop screenshot cannot answer whether the intermediate arrangement fits.

If the project customizes breakpoints, read that configuration before assuming the default thresholds.

3. Adding truncation without letting the flex item shrink

A long filename can push an action out of a flex row even when the text has truncation styles. The automatic minimum width of a flex item can be based on its content; min-width: 0 lets the relevant item shrink below that content size. MDN documents the automatic minimum-size behavior.

Consider this illustrative before-and-after change. The desired behavior is a shortened filename with the Open action still visible.

tsx

Verify the example in the actual parent layout with a long unbroken filename. Do not assume the nearest text element is the only constrained flex item. For content users must read in full, wrapping may be a better product decision than truncation.

4. Creating one-off values before checking the theme

Arbitrary values are useful for real exceptions. The review question is whether a value expresses a deliberate exception or repeats an existing design decision under a new name.

Tailwind v4 theme variables define values that connect to utility APIs, including color and typography namespaces. The theme documentation explains how those variables produce utilities.

When a caption introduces a new size or muted color, inspect the corresponding existing pattern first. Replace it only when the intended role matches. A chart color, customer brand color, and body-text color need not follow the same rule. For shadcn projects, see the CSS-variable theming guide.

5. Removing the focus indicator without a replacement

A button's hover style is not evidence that keyboard users can locate focus. Tailwind provides separate state variants, including focus-visible:, so inspect the focus treatment explicitly. Tailwind's state-variant guide documents those selectors; WCAG's Focus Visible guidance explains the user need.

Tab through the changed controls on their real backgrounds. Check whether an outline was removed, whether the replacement is distinguishable, and whether a parent clips it. Prefer the project's established focus treatment over inventing another one for a single button.

6. Assuming dark mode follows any dark-looking wrapper

The dark: variant depends on the configured activation method. Tailwind defaults to the system color-scheme preference and also supports custom selector-based activation. A dark background alone does not activate the variant. Tailwind's dark-mode documentation covers both approaches.

Inspect the actual theme trigger, then preview the component in both modes. Look at foreground/background pairs, muted copy, borders, and focus indicators together. A correctly activated mode can still contain a poorly chosen color pair.

Use the symptom to choose the next check

SymptomFirst inspection
A variant has no stylingComplete class names and source scanning
Layout changes at the wrong widthBase utilities and breakpoint configuration
Long text pushes an action awayMinimum widths in the flex ancestry
One screen feels unrelatedExisting semantic tokens and component variants
Keyboard focus disappearsFocus styles and clipping ancestors
Dark styles never activateSystem preference or configured selector

Change the smallest cause you can explain, then reproduce the original symptom again. For a team-wide pattern of exceptions, run a design system consistency audit.

Design Bug Bot reviews repository components, tokens, and layout risks with suggested fixes; screenshots depend on successful rendering.

Frequently asked

Are arbitrary Tailwind values bad practice?
Use them for a justified exception. Repeated decisions deserve an explicit shared rule, while a one-off illustration may reasonably need a value outside the product scale.
Should I fix every overflow issue with overflow-hidden?
First decide whether the content should wrap, scroll locally, truncate, or remain fully visible. Hiding the result is only appropriate when clipping is the intended behavior.

Published

Sep 7, 2026

Read time

5 min

Tags

GuideDesign QAReactDesign Bug Bot

Share