Repository navigation
fix: three Tailwind 4 cascade regressions (.underline, .client, duplicated @apply utilities) - #60
Merged
Merged
Conversation
`.underline` is the brush-stroke emphasis span: a blue word with the hand-drawn
underline.svg painted under it by an `::after`. It has been rendering with TWO
underlines since 3.0.0 — the brush stroke and a plain rule struck through the
text.
The rule already asks for the right thing (`@apply relative no-underline …`), and
it is more specific than anything Tailwind generates: `:is(h1,…,.h6) .underline`
is (0,2,0) against the utility's (0,1,0). It loses anyway, because the class name
collides with Tailwind's built-in `underline` utility and cascade layers beat
specificity:
@layer base { :is(h1,…,.h6) .underline { … text-decoration-line: none } }
@layer utilities { .underline { text-decoration-line: underline } }
Nothing a consumer writes on the element can reach it either.
This was invisible in the Tailwind 3 -> 4 migration diff, which is why it slipped
through: v3 emitted no cascade layers at all, so plain source order decided it and
the component rule — emitted after the utility — won.
Restated inside `@layer utilities` so it is judged against the built-in on equal
terms, where the higher specificity finally settles it. Deliberately NOT
`@utility underline { … }`: that would replace Tailwind's built-in everywhere and
consumers could no longer use `underline` as a plain text-decoration utility.
Verified in the built example: inside an `<h2>` and inside a `<div class="h3">`
the span computes `text-decoration-line: none` with the 6px stroke intact, while
an `.underline` in a `<p>` still computes `underline` and gets no stroke.
The example gains an "Emphasis inside a title" sample showing `.underline` and
`.highlight`, which is what would have caught this by eye.
`.client` applied `flex-basis` twice in one `@apply` — `lg:basis-1/6` and `lg:basis-1/4`. Under Tailwind 4 the winner is decided by the utilities' order in the generated stylesheet rather than by the order written, and `basis-1/6` came out on top, so the row laid out at 6 per line instead of 4. The knock-on effect is worse than the layout: `.clients .client img` is `sm:w-full`, so each logo resolves to the width of its squeezed box and every one renders at two thirds of its intended size. 25% is the value the original theme shipped, unconditionally and inside its `min-width: 1024px` block. Same class of mistake as the duplicated `flex-row` in `.brick-feature` (#57).
Neither changes a byte of emitted CSS; both remove the trap that produced #57 and the `.client` basis bug. `.nav-submenu` listed `flex` and `hidden` in the same `@apply`, plus a second `opacity-0` and a second `absolute`. The generated order happens to resolve to `display: none`, which is what the open state (`display: block`) expects — but a duplicated `display` inside one `@apply` is exactly what silently broke `.brick-feature`. `.possibilities` listed `items-center` twice.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Tailwind v4 cascade-layer regressions where layer order caused previously-correct component styling to be overridden by built-in utilities, and removes duplicated/conflicting utilities in @apply blocks to prevent similar breakages.
Changes:
- Fixes heading
.underlineso it no longer inherits Tailwind’s built-inunderlinetext decoration under v4 layer ordering by restating the reset in@layer utilities. - Removes duplicated/conflicting utilities in
@applyfor.client(fixinglg:basis-*layout) and.nav-submenu/.possibilities(cleanup to avoid future cascade traps). - Adds an example snippet to visually cover emphasis styling inside headings.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/possibilities.css | Removes redundant items-center from the @apply list to eliminate duplicated utilities. |
| src/components/nav.css | Cleans up conflicting/duplicated @apply utilities for .nav-submenu while preserving the open/closed behavior (hidden → block). |
| src/components/clients.css | Removes conflicting lg:basis-* utilities so lg:basis-1/4 consistently wins under Tailwind v4. |
| src/base/index.css | Adds a targeted @layer utilities override so heading .underline correctly resets text-decoration-line under v4 cascade layers. |
| example/index.html | Adds a heading example that exercises .underline and .highlight together for visual verification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three Tailwind-4 cascade regressions found while rebuilding workadventu.re against 3.0.3, plus a cleanup of the pattern that caused two of them.
All of these were invisible in the v3 → v4 migration diff, because Tailwind 3 emitted no cascade layers at all. Its output is flat, so plain source order decided everything. v4 puts the design system's rules in
@layer base/@layer componentsand Tailwind's own utilities in@layer utilities, and layer order beats both specificity and source order — so outcomes flipped without anyone editing a rule.1.
.underlinedraws two underlines.underlineis the brush-stroke emphasis span. Since 3.0.0 it has rendered the stroke and a plain rule struck through the text.The rule already asks for the right thing, and it is more specific than anything Tailwind generates —
:is(h1,…,.h6) .underlineis (0,2,0) against the utility's (0,1,0). It loses anyway, because the class name collides with Tailwind's built-inunderline:Nothing a consumer writes on the element can reach it either.
Fix: restate the reset inside
@layer utilities, where it is judged against the built-in on equal terms and the higher specificity finally settles it.Deliberately not
@utility underline { … }— that would replace Tailwind's built-in everywhere, so consumers could no longer useunderlineas a plain text-decoration utility outside a heading. This keeps the fix to the one place the design system owns. (@utility containerinutilities/general.cssis the opposite case, where replacing the built-in is exactly what you want.)2.
.clientlays out at 6 per line instead of 4Under v4 the winner is decided by the utilities' order in the generated sheet, not by the order written, and
basis-1/6comes out on top.The knock-on effect is worse than the layout:
.clients .client imgissm:w-full, so each logo resolves to the width of its squeezed box and every one renders at two thirds of its intended size. 25% is the value the original theme shipped, both unconditionally and inside itsmin-width: 1024pxblock.Same class of mistake as the duplicated
flex-rowin.brick-feature(#57) — and released after that fix, which is why this PR also does the sweep below.3. Duplicated utilities elsewhere (no output change)
I swept every
@applyinsrc/for two utilities from the same property group. Four sites; two were the bugs above, two are harmless but worth removing since this pattern has now caused two real regressions:.nav-submenulistedflexandhidden, plus a secondopacity-0and a secondabsolute. The generated order happens to resolve todisplay: none, which is what the open state (display: block) expects — so it works today, by luck..possibilitieslisteditems-centertwice.I also swept for the other pattern — component classes shadowed by a same-named built-in utility — by generating every one of the 263 class names this package defines through a real Tailwind 4 build and diffing against
@layer utilities..underlineis the only genuine collision. The other 19 hits are the package's own@utilitydefinitions (.h1–.h4,.paragraph*,.container,.bg-blur,.brick,.cursor,.col-3/4), which override their built-ins on purpose.Verified
Against the built example in Chrome:
.underlinein<h2>and in<div class="h3">text-decoration-line: none, 6px stroke intact.underlinein a<p>(control)underline, no stroke — not a breaking change.clients .clientat ≥1024pxflex-basis: 25%.nav-submenudisplay: noneclosed,blockopen — unchangedThe example gains an "Emphasis inside a title" sample showing
.underlineand.highlight, which is what would have caught #1 by eye.Not in this PR
The heading type scale (42/34/28/24/18/18) is smaller than the theme workadventu.re actually ships (44/40/36/32/28/24), widening to −36% at h5. That is not a v4 regression —
v2.0.4'stheming/fontSize.tscarries the same tokens — so the two scales simply never agreed. The site overrides it locally for now. If this package is meant to describe that site, its heading scale should probably become those numbers; happy to open a separate PR, but it changes every consumer so it wants a deliberate decision.🤖 Generated with Claude Code