Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- _Experimental_: Add `@container-size` utility ([#18901](https://github.com/tailwindlabs/tailwindcss/pull/18901))

### Fixed

- Improve canonicalizations for `tracking-*` utilities ([#19827](https://github.com/tailwindlabs/tailwindcss/pull/19827))

## [4.2.2] - 2026-03-18

### Fixed
Expand Down
34 changes: 34 additions & 0 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,40 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
await expectCombinedCanonicalization(input, candidates.trim(), expected)
})
})

// https://github.com/tailwindlabs/tailwindcss-intellisense/issues/1558
test.each([
['tracking-[-0.05em]', 'tracking-tighter'],
['tracking-[-0.025em]', 'tracking-tight'],
['tracking-[0em]', 'tracking-normal'],
['tracking-[0.025em]', 'tracking-wide'],
['tracking-[0.05em]', 'tracking-wider'],
['tracking-[0.1em]', 'tracking-widest'],

// Negative values that don't make sense
// See: https://tailwindcss.com/docs/letter-spacing#using-negative-values
['-tracking-tighter', 'tracking-wider'],
['-tracking-tight', 'tracking-wide'],
['-tracking-normal', 'tracking-normal'],
['-tracking-wide', 'tracking-tight'],
['-tracking-wider', 'tracking-tighter'],
])(testName, { timeout }, async (candidate, expected) => {
await expectCanonicalization(
css`
@import 'tailwindcss';
@theme {
--tracking-tighter: -0.05em;
--tracking-tight: -0.025em;
--tracking-normal: 0em;
--tracking-wide: 0.025em;
--tracking-wider: 0.05em;
--tracking-widest: 0.1em;
}
`,
candidate,
expected,
)
})
})

describe('theme to var', () => {
Expand Down
56 changes: 46 additions & 10 deletions packages/tailwindcss/src/canonicalize-candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,11 +1128,29 @@ function arbitraryUtilities(candidate: Candidate, options: InternalCanonicalizeO
// Find a corresponding utility for the same signature
let replacements = utilities.get(targetSignature)

// Multiple utilities can map to the same signature. Not sure how to migrate
// this one so let's just skip it for now.
//
// TODO: Do we just migrate to the first one?
if (replacements.length > 1) return
// Multiple utilities can map to the same signature.
if (replacements.length > 1) {
// Prefer positive values over negative values
let maybeReplacement: string | undefined = undefined
for (let replacement of replacements) {
if (replacement[0] === '-') continue // Skip negative values

// If multiple non-negative replacements exists then we are unsure
// what to do, so let's bail.
if (maybeReplacement) return

// Consider this replacement
maybeReplacement = replacement
}

if (maybeReplacement) {
for (let replacementCandidate of parseCandidate(designSystem, maybeReplacement)) {
yield replacementCandidate
}
}

return
}

// If we didn't find any replacement utilities, let's try to strip the
// modifier and find a replacement then. If we do, we can try to re-add the
Expand Down Expand Up @@ -1353,11 +1371,29 @@ function bareValueUtilities(candidate: Candidate, options: InternalCanonicalizeO
// Find a corresponding utility for the same signature
let replacements = utilities.get(targetSignature)

// Multiple utilities can map to the same signature. Not sure how to migrate
// this one so let's just skip it for now.
//
// TODO: Do we just migrate to the first one?
if (replacements.length > 1) return
// Multiple utilities can map to the same signature.
if (replacements.length > 1) {
// Prefer positive values over negative values
let maybeReplacement: string | undefined = undefined
for (let replacement of replacements) {
if (replacement[0] === '-') continue // Skip negative values

// If multiple non-negative replacements exists then we are unsure
// what to do, so let's bail.
if (maybeReplacement) return

// Consider this replacement
maybeReplacement = replacement
}

if (maybeReplacement) {
for (let replacementCandidate of parseCandidate(designSystem, maybeReplacement)) {
yield replacementCandidate
}
}

return
}

// If we didn't find any replacement utilities, let's try to strip the
// modifier and find a replacement then. If we do, we can try to re-add the
Expand Down