diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad1df938f5f..1421e827fbd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ensure `@keyframes` are correctly emitted when using a prefixed setup ([#16850](https://github.com/tailwindlabs/tailwindcss/pull/16850)) - Don't swallow `@utility` declarations when `@apply` is used in nested rules ([#16940](https://github.com/tailwindlabs/tailwindcss/pull/16940)) - Ensure `outline-hidden` behaves like `outline-none` in non-`forced-colors` mode ([#](https://github.com/tailwindlabs/tailwindcss/pull/)) +- Allow `!important` on CSS variables again ([#16873](https://github.com/tailwindlabs/tailwindcss/pull/16873)) ## [4.0.9] - 2025-02-25 diff --git a/packages/tailwindcss/src/compile.ts b/packages/tailwindcss/src/compile.ts index cf20ada9ec72..cd822b368cba 100644 --- a/packages/tailwindcss/src/compile.ts +++ b/packages/tailwindcss/src/compile.ts @@ -304,7 +304,7 @@ function applyImportant(ast: AstNode[]): void { continue } - if (node.kind === 'declaration' && !(node.property[0] === '-' && node.property[1] === '-')) { + if (node.kind === 'declaration') { node.important = true } else if (node.kind === 'rule' || node.kind === 'at-rule') { applyImportant(node.nodes) diff --git a/packages/tailwindcss/src/important.test.ts b/packages/tailwindcss/src/important.test.ts index 7a27fb6e6d2a..b3594219b6f4 100644 --- a/packages/tailwindcss/src/important.test.ts +++ b/packages/tailwindcss/src/important.test.ts @@ -110,7 +110,7 @@ test('variables in utilities should not be marked as important', async () => { } .ease-out\\! { - --tw-ease: var(--ease-out); + --tw-ease: var(--ease-out) !important; transition-timing-function: var(--ease-out) !important; }