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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Canonicalization: preserve the original unit in arbitrary values instead of normalizing to base units (e.g. `-mt-[20in]` → `mt-[-20in]`, not `mt-[-1920px]`) ([#19988](https://github.com/tailwindlabs/tailwindcss/pull/19988))
- Canonicalization: migrate arbitrary `:has()` variants from `[&:has(…)]` to `has-[…]` ([#19991](https://github.com/tailwindlabs/tailwindcss/pull/19991))
- Upgrade: don’t migrate inline `style` attributes ([#19918](https://github.com/tailwindlabs/tailwindcss/pull/19918))
- Allow multiple `@utility` definitions with the same name but different value types ([#19777](https://github.com/tailwindlabs/tailwindcss/pull/19777))

## [4.2.4] - 2026-04-21

Expand Down
28 changes: 26 additions & 2 deletions packages/tailwindcss/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,19 @@ function compileBaseUtility(candidate: Candidate, designSystem: DesignSystem) {

let compiledNodes = utility.compileFn(candidate)
if (compiledNodes === undefined) continue
if (compiledNodes === null) return asts
if (compiledNodes === null) {
// `null` means that the result is invalid and that this plugin should not
// result in any CSS, but that doesn't mean that subsequent plugins are
// invalid as well.
//
// However, for backwards compatibility with `matchUtilities` this means
// that we do need to bail entirely: plugins that handle a specific
// arbitrary value type prevent falling through to other plugins if the
// result is invalid for that plugin
if (utility.options?.types?.length) return asts

continue
}
asts.push(compiledNodes)
}

Expand All @@ -299,7 +311,19 @@ function compileBaseUtility(candidate: Candidate, designSystem: DesignSystem) {

let compiledNodes = utility.compileFn(candidate)
if (compiledNodes === undefined) continue
if (compiledNodes === null) return asts
if (compiledNodes === null) {
// `null` means that the result is invalid and that this plugin should not
// result in any CSS, but that doesn't mean that subsequent plugins are
// invalid as well.
//
// However, for backwards compatibility with `matchUtilities` this means
// that we do need to bail entirely: plugins that handle a specific
// arbitrary value type prevent falling through to other plugins if the
// result is invalid for that plugin
if (utility.options?.types?.length) return asts

continue
}
asts.push(compiledNodes)
}

Expand Down
34 changes: 34 additions & 0 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29979,4 +29979,38 @@ describe('custom utilities', () => {
}"
`)
})

test('multiple @utility definitions with the same name but different value types', async () => {
let input = css`
@theme {
--color-red-500: #ef4444;
--spacing: 0.25rem;
}

@utility foo-* {
color: --value(--color-*);
}

@utility foo-* {
font-size: --spacing(--value(number));
}

@tailwind utilities;
`

expect(await compileCss(input, ['foo-red-500', 'foo-123'])).toMatchInlineSnapshot(`
":root, :host {
--color-red-500: #ef4444;
--spacing: .25rem;
}

.foo-123 {
font-size: calc(var(--spacing) * 123);
}

.foo-red-500 {
color: var(--color-red-500);
}"
`)
})
})