Skip to content

Commit 233aca0

Browse files
Add prefers-reduced-transparency variants
Co-authored-by: Luke Warlow <[email protected]>
1 parent cc8c069 commit 233aca0

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

+14
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,20 @@ exports[`getVariants 1`] = `
23822382
"selectors": [Function],
23832383
"values": [],
23842384
},
2385+
{
2386+
"hasDash": true,
2387+
"isArbitrary": false,
2388+
"name": "transparency-safe",
2389+
"selectors": [Function],
2390+
"values": [],
2391+
},
2392+
{
2393+
"hasDash": true,
2394+
"isArbitrary": false,
2395+
"name": "transparency-reduce",
2396+
"selectors": [Function],
2397+
"values": [],
2398+
},
23852399
{
23862400
"hasDash": true,
23872401
"isArbitrary": false,

packages/tailwindcss/src/variants.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,26 @@ test('landscape', () => {
15161516
`)
15171517
})
15181518

1519+
test('transparency-safe', () => {
1520+
expect(run(['transparency-safe:flex'])).toMatchInlineSnapshot(`
1521+
"@media (prefers-reduced-transparency: no-preference) {
1522+
.transparency-safe\\:flex {
1523+
display: flex;
1524+
}
1525+
}"
1526+
`)
1527+
})
1528+
1529+
test('transparency-reduce', () => {
1530+
expect(run(['transparency-reduce:flex'])).toMatchInlineSnapshot(`
1531+
"@media (prefers-reduced-transparency: reduce) {
1532+
.transparency-reduce\\:flex {
1533+
display: flex;
1534+
}
1535+
}"
1536+
`)
1537+
})
1538+
15191539
test('contrast-more', () => {
15201540
expect(run(['contrast-more:flex'])).toMatchInlineSnapshot(`
15211541
"@media (prefers-contrast: more) {

packages/tailwindcss/src/variants.ts

+7
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,13 @@ export function createVariants(theme: Theme): Variants {
690690
staticVariant('portrait', ['@media (orientation: portrait)'], { compounds: false })
691691
staticVariant('landscape', ['@media (orientation: landscape)'], { compounds: false })
692692

693+
staticVariant('transparency-safe', ['@media (prefers-reduced-transparency: no-preference)'], {
694+
compounds: false,
695+
})
696+
staticVariant('transparency-reduce', ['@media (prefers-reduced-transparency: reduce)'], {
697+
compounds: false,
698+
})
699+
693700
staticVariant('ltr', ['&:where([dir="ltr"], [dir="ltr"] *)'])
694701
staticVariant('rtl', ['&:where([dir="rtl"], [dir="rtl"] *)'])
695702

0 commit comments

Comments
 (0)