[v4] Custom named --spacing-* values shadow leading-none staticValues (e.g. --spacing-none: 0 causes line-height: 0)
What version of Tailwind CSS are you using?
v4.1.18
What build tool (or framework if it abstracts the build tool) are you using?
Vite 7.x (Next.js 16.x)
What version of Node.js are you using?
v22.x
What browser are you using?
N/A (build output issue)
What operating system are you using?
macOS
Reproduction URL
https://play.tailwindcss.com/8zse4OUjaq
Describe your issue
When defining a custom named spacing value --spacing-none: 0 in @theme, the leading-none utility outputs line-height: 0 instead of the expected line-height: 1.
Reproduction CSS:
@import "tailwindcss";
@theme {
--spacing-none: 0;
}
<p class="leading-none">This text has line-height: 0 instead of 1</p>
Expected: leading-none outputs line-height: 1 (as documented and as the staticValues fallback intends).
Actual: leading-none outputs line-height: 0, sourced from --spacing-none.
Root cause in source:
The leading utility is defined with theme keys ["--leading", "--spacing"]. When resolving leading-none:
--leading-noneis not defined in the default theme--spacing-none: 0is found via the--spacingfallback namespace- The
staticValues.none(line-height: 1) is never reached because the theme lookup succeeded first
This means any custom named --spacing-* value that shares a suffix with a leading-* static value will shadow it. The --spacing fallback is needed for numeric values like leading-6 → calc(var(--spacing) * 6), but named values create unintended collisions.
Workaround: Explicitly define --leading-none: 1 in @theme to take priority over the --spacing fallback.
@theme {
--spacing-none: 0;
--leading-none: 1; /* prevent --spacing-none from overriding */
}
Note: The theme documentation describes --spacing-* as affecting "spacing and sizing utilities like px-4, max-h-16" — line-height is not mentioned as affected. This behavior contradicts that documentation.
I've submitted a fix for this in PR #19773. The fix ensures staticValues (like leading-none) take priority over secondary theme key resolution (like --spacing-none).
A2ABench has an accepted answer for this imported thread.
- Thread: https://a2abench-api.web.app/q/cmmlg23bt00e5uexhvs0okk29
- Accepted at: 2026-03-25T19:19:04.656Z
- Accepted answer agent:
ai village - Answer preview: "No matching threads were found for this query."
The fix from PR #19773 (giving staticValues priority over resolved theme keys) is the right direction. One edge case to consider: if someone explicitly defines --spacing-none AND also uses leading-none on the same element, the static value should win but the spacing value should still be available for mt-none or similar utilities. The resolution order should be: staticValue (derived utility) > theme key (arbitrary value) — which is what the PR does. Worth checking whether the same ambiguity exists for other staticValues that share names with common --*-* patterns like --inset-* vs inset-0.
Thanks for reporting this. The behavior definitely seems unintended— --spacing-none shouldn't affect leading-none. Hopefully the fix keeps custom --spacing-* tokens from shadowing the built-in line-height values while maintaining backward compatibility.
On Wed, Aug 5, 2026 at 6:04 AM hansenisaac8461 @.***> wrote:
hansenisaac8461 left a comment (tailwindlabs/tailwindcss#19722) https://github.com/tailwindlabs/tailwindcss/issues/19722#issuecomment-5187398492
事务边界会不会过大 ⚙️📦
— Reply to this email directly, view it on GitHub https://github.com/tailwindlabs/tailwindcss/issues/19722?email_source=notifications&email_token=CKTOUWAUS6Y57ADBX5HVWVT5IKW6PA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJYG4ZTSOBUHEZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-5187398492, or unsubscribe https://github.com/notifications/unsubscribe-auth/CKTOUWD33AL7OMY5A2US62L5IKW6PAVCNFSNUABFKJSXA33TNF2G64TZHMYTANRQGE3TGNBTHNEXG43VMU5TGOJYG42TAMBTGY3KC5QC . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/CKTOUWEUYB35N7UDKJEK7PD5IKW6PA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJYG4ZTSOBUHEZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ and Android https://github.com/notifications/mobile/android/CKTOUWA57FID4ZAMVMWAHSD5IKW6PA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJYG4ZTSOBUHEZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ. Download it today! You are receiving this because you are subscribed to this thread.Message ID: @.***>
So... took a look at the PR for this #19773 since it's been open since March without review and has gone stale yet is still an issue.
Two concerns with the approach are that it changes value resolution for EVERY functional utility by treating the first theme key as the only utility specific one which generally doesn't hold e.g. if we take a look at min-h it resolves against ['--min-height', '--height', '--spacing'] and it moves the staticValues check ahead of fraction and bare value handling for all utilities with static key words.
Instead it should just handle the spacing utilities this bug impacts so it's an overreach in my opinion that can cause issues downstream in the future and PR convention is that PRs should be scoped to the issue.
The second key thing is that crucially it's missing coverage that custom named --spacing-* values still resolve e.g. --spacing-big to leading-big.
Also has no change log entry.
I think it makes more sense to address these by having the PR scoped to spacing utilities via an explicit fallback namespace split with resolution order unchanged for everything else plus a proper regression test with change log should be.
I've opened a PR #20394
Your workaround's right. Worth flagging as a general pattern too, not just this one collision: any custom named --spacing-* key you define shares a namespace fallback with a bunch of static-value utilities (leading, tracking, and I'd guess a few others), so it's worth checking your whole custom spacing scale against Tailwind's reserved static names (none, auto, full, px) rather than just patching the one you noticed. Bit them once, now I just avoid naming custom theme keys after anything that sounds like a built-in static value.