Skip to content

Commit 7bfbe2a

Browse files
committed
Add prefers-reduced-transparency variants
1 parent a8c54ac commit 7bfbe2a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -8240,6 +8240,20 @@ exports[`getVariants 1`] = `
82408240
"selectors": [Function],
82418241
"values": [],
82428242
},
8243+
{
8244+
"hasDash": true,
8245+
"isArbitrary": false,
8246+
"name": "transparency-safe",
8247+
"selectors": [Function],
8248+
"values": [],
8249+
},
8250+
{
8251+
"hasDash": true,
8252+
"isArbitrary": false,
8253+
"name": "transparency-reduce",
8254+
"selectors": [Function],
8255+
"values": [],
8256+
},
82438257
{
82448258
"hasDash": true,
82458259
"isArbitrary": false,

packages/tailwindcss/src/variants.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,26 @@ test('landscape', async () => {
19031903
expect(await run(['landscape/foo:flex'])).toEqual('')
19041904
})
19051905

1906+
test('transparency-safe', async () => {
1907+
expect(await run(['transparency-safe:flex'])).toMatchInlineSnapshot(`
1908+
"@media (prefers-reduced-transparency: no-preference) {
1909+
.transparency-safe\\:flex {
1910+
display: flex;
1911+
}
1912+
}"
1913+
`)
1914+
})
1915+
1916+
test('transparency-reduce', async () => {
1917+
expect(await run(['transparency-reduce:flex'])).toMatchInlineSnapshot(`
1918+
"@media (prefers-reduced-transparency: reduce) {
1919+
.transparency-reduce\\:flex {
1920+
display: flex;
1921+
}
1922+
}"
1923+
`)
1924+
})
1925+
19061926
test('contrast-more', async () => {
19071927
expect(await run(['contrast-more:flex'])).toMatchInlineSnapshot(`
19081928
"@media (prefers-contrast: more) {

packages/tailwindcss/src/variants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,9 @@ export function createVariants(theme: Theme): Variants {
11341134

11351135
staticVariant('forced-colors', ['@media (forced-colors: active)'])
11361136

1137+
staticVariant('transparency-safe', ['@media (prefers-reduced-transparency: no-preference)'])
1138+
staticVariant('transparency-reduce', ['@media (prefers-reduced-transparency: reduce)'])
1139+
11371140
return variants
11381141
}
11391142

0 commit comments

Comments
 (0)