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 `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))

### Fixed

- Remove invalid `!important` on CSS variable declarations ([#16668](https://github.com/tailwindlabs/tailwindcss/pull/16668))

## [4.0.7] - 2025-02-18

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function applyImportant(ast: AstNode[]): void {
continue
}

if (node.kind === 'declaration') {
if (node.kind === 'declaration' && node.property[0] !== '-' && node.property[1] !== '-') {
node.important = true
} else if (node.kind === 'rule' || node.kind === 'at-rule') {
applyImportant(node.nodes)
Expand Down
29 changes: 29 additions & 0 deletions packages/tailwindcss/src/important.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test } from 'vitest'
import { compile } from '.'
import { compileCss } from './test-utils/run'

const css = String.raw

Expand Down Expand Up @@ -87,3 +88,31 @@ test('Utilities can be wrapped with a selector and marked as important', async (
"
`)
})

test('variables in utilities should not be marked as important', async () => {
expect(
await compileCss(
css`
@theme {
--ease-out: cubic-bezier(0, 0, 0.2, 1);
}
@tailwind utilities;
`,
['ease-out!'],
),
).toMatchInlineSnapshot(`
":root, :host {
--ease-out: cubic-bezier(0, 0, .2, 1);
}

.ease-out\\! {
--tw-ease: var(--ease-out);
transition-timing-function: var(--ease-out) !important;
}

@property --tw-ease {
syntax: "*";
inherits: false
}"
`)
})