File tree 3 files changed +77
-0
lines changed
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
21
- Do not emit ` @keyframes ` in ` @theme reference ` ([ #16120 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16120 ) )
22
22
- Discard invalid declarations when parsing CSS ([ #16093 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16093 ) )
23
23
- Do not emit empty CSS rules and at-rules ([ #16121 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16121 ) )
24
+ - Handle ` @variant ` when at the top-level of a stylesheet ([ #16129 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16129 ) )
24
25
25
26
## [ 4.0.1] - 2025-01-29
26
27
Original file line number Diff line number Diff line change @@ -3510,6 +3510,38 @@ describe('@variant', () => {
3510
3510
background : white;
3511
3511
}
3512
3512
}
3513
+
3514
+ @variant hover {
3515
+ @variant landscape {
3516
+ .btn2 {
3517
+ color : red;
3518
+ }
3519
+ }
3520
+ }
3521
+
3522
+ @variant hover {
3523
+ .foo {
3524
+ color : red;
3525
+ }
3526
+ @variant landscape {
3527
+ .bar {
3528
+ color : blue;
3529
+ }
3530
+ }
3531
+ .baz {
3532
+ @variant portrait {
3533
+ color : green;
3534
+ }
3535
+ }
3536
+ }
3537
+
3538
+ @media something {
3539
+ @variant landscape {
3540
+ @page {
3541
+ color : red;
3542
+ }
3543
+ }
3544
+ }
3513
3545
` ,
3514
3546
[ ] ,
3515
3547
) ,
@@ -3522,6 +3554,38 @@ describe('@variant', () => {
3522
3554
.btn {
3523
3555
background: #fff;
3524
3556
}
3557
+ }
3558
+
3559
+ @media (hover: hover) {
3560
+ @media (orientation: landscape) {
3561
+ :scope:hover .btn2 {
3562
+ color: red;
3563
+ }
3564
+ }
3565
+
3566
+ :scope:hover .foo {
3567
+ color: red;
3568
+ }
3569
+
3570
+ @media (orientation: landscape) {
3571
+ :scope:hover .bar {
3572
+ color: #00f;
3573
+ }
3574
+ }
3575
+
3576
+ @media (orientation: portrait) {
3577
+ :scope:hover .baz {
3578
+ color: green;
3579
+ }
3580
+ }
3581
+ }
3582
+
3583
+ @media something {
3584
+ @media (orientation: landscape) {
3585
+ @page {
3586
+ color: red;
3587
+ }
3588
+ }
3525
3589
}"
3526
3590
` )
3527
3591
} )
Original file line number Diff line number Diff line change @@ -244,6 +244,11 @@ async function parseCss(
244
244
return WalkAction . Stop
245
245
}
246
246
} )
247
+
248
+ // No `@slot` found, so this is still a regular `@variant` at-rule
249
+ if ( node . name === '@variant' ) {
250
+ variantNodes . push ( node )
251
+ }
247
252
}
248
253
}
249
254
@@ -429,6 +434,13 @@ async function parseCss(
429
434
replaceWith ( node . nodes )
430
435
}
431
436
437
+ walk ( node . nodes , ( node ) => {
438
+ if ( node . kind !== 'at-rule' ) return
439
+ if ( node . name !== '@variant' ) return
440
+
441
+ variantNodes . push ( node )
442
+ } )
443
+
432
444
return WalkAction . Skip
433
445
}
434
446
You can’t perform that action at this time.
0 commit comments