Skip to content

Commit 7fd53f1

Browse files
committed
Make @apply treat utilities as not important unless they have a !
1 parent 592c959 commit 7fd53f1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/tailwindcss/src/apply.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export function substituteAtApply(ast: AstNode[], designSystem: DesignSystem) {
176176
// with.
177177
let candidates = Object.keys(candidateOffsets)
178178
let compiled = compileCandidates(candidates, designSystem, {
179+
respectImportant: false,
179180
onInvalidCandidate: (candidate) => {
180181
// When using prefix, make sure prefix is used in candidate
181182
if (designSystem.theme.prefix && !candidate.startsWith(designSystem.theme.prefix)) {

packages/tailwindcss/src/index.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,41 @@ describe('@apply', () => {
777777
}"
778778
`)
779779
})
780+
781+
// https://github.com/tailwindlabs/tailwindcss/issues/18400
782+
it('should ignore the design systems `important` flag when using @apply', async () => {
783+
expect(
784+
await compileCss(
785+
css`
786+
@import 'tailwindcss/utilities' important;
787+
.flex-explicitly-important {
788+
@apply flex!;
789+
}
790+
.flex-not-important {
791+
@apply flex;
792+
}
793+
`,
794+
['flex'],
795+
{
796+
async loadStylesheet(_, base) {
797+
return {
798+
content: '@tailwind utilities;',
799+
base,
800+
path: '',
801+
}
802+
},
803+
},
804+
),
805+
).toMatchInlineSnapshot(`
806+
".flex, .flex-explicitly-important {
807+
display: flex !important;
808+
}
809+
810+
.flex-not-important {
811+
display: flex;
812+
}"
813+
`)
814+
})
780815
})
781816

782817
describe('arbitrary variants', () => {

0 commit comments

Comments
 (0)