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
8 changes: 7 additions & 1 deletion packages/tailwindcss/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ export function optimizeAst(

// Track variables defined in `@theme`
if (context.theme && node.property[0] === '-' && node.property[1] === '-') {
cssThemeVariables.get(parent).add(node)
if (!context.keyframes) {
cssThemeVariables.get(parent).add(node)
}
}

// Track used CSS variables
Expand Down Expand Up @@ -354,6 +356,10 @@ export function optimizeAst(

// AtRule
else if (node.kind === 'at-rule') {
if (node.name === '@keyframes') {
context = { ...context, keyframes: true }
}

let copy = { ...node, nodes: [] }
for (let child of node.nodes) {
transform(child, copy.nodes, context, depth + 1)
Expand Down
38 changes: 38 additions & 0 deletions packages/tailwindcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,44 @@ describe('Parsing theme values from CSS', () => {
`)
})

// https://github.com/tailwindlabs/tailwindcss/issues/16374
test('custom properties in keyframes preserved', async () => {
expect(
await compileCss(
css`
@theme {
--animate-foo: used 1s infinite;

@keyframes used {
to {
--other: var(--angle);
--angle: 360deg;
}
}
}

@tailwind utilities;
`,
['animate-foo'],
),
).toMatchInlineSnapshot(`
":root, :host {
--animate-foo: used 1s infinite;
}

.animate-foo {
animation: var(--animate-foo);
}

@keyframes used {
to {
--other: var(--angle);
--angle: 360deg;
}
}"
`)
})

test('keyframes are generated when used in an animation using `@theme inline`', async () => {
expect(
await compileCss(
Expand Down