Skip to content

Commit 1c2ad57

Browse files
Add pointer-* variants (#16946)
Adds new variants under a feature flag: - `pointer-none` - `pointer-coarse` - `pointer-fine` - `any-pointer-none` - `any-pointer-coarse` - `any-pointer-fine`
1 parent 2eecb4d commit 1c2ad57

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- _Experimental_: Add `details-content` variant ([#15319](https://github.com/tailwindlabs/tailwindcss/pull/15319))
1313
- _Experimental_: Add `inverted-colors` variant ([#11693](https://github.com/tailwindlabs/tailwindcss/pull/11693))
1414
- _Experimental_: Add `scripting`, `scripting-none`, and `scripting-initial` variants ([#11929](https://github.com/tailwindlabs/tailwindcss/pull/11929))
15+
- _Experimental_: Add `pointer-none`, `pointer-coarse`, and `pointer-fine` variant ([#16946](https://github.com/tailwindlabs/tailwindcss/pull/16946))
16+
- _Experimental_: Add `any-pointer-none`, `any-pointer-coarse`, and `any-pointer-fine` variants ([#16941](https://github.com/tailwindlabs/tailwindcss/pull/16941))
1517
- _Experimental_: Add `user-valid` and `user-invalid` variants ([#12370](https://github.com/tailwindlabs/tailwindcss/pull/12370))
1618
- _Experimental_: Add `wrap-anywhere`, `wrap-break-word`, and `wrap-normal` utilities ([#12128](https://github.com/tailwindlabs/tailwindcss/pull/12128))
1719
- Add `col-<number>` and `row-<number>` utilities for `grid-column` and `grid-row` ([#15183](https://github.com/tailwindlabs/tailwindcss/pull/15183))

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

+48
Original file line numberDiff line numberDiff line change
@@ -8447,6 +8447,12 @@ exports[`getVariants 1`] = `
84478447
"print",
84488448
"forced-colors",
84498449
"inverted-colors",
8450+
"pointer-none",
8451+
"pointer-coarse",
8452+
"pointer-fine",
8453+
"any-pointer-none",
8454+
"any-pointer-coarse",
8455+
"any-pointer-fine",
84508456
"scripting-initial",
84518457
"scripting-none",
84528458
"scripting",
@@ -9185,6 +9191,48 @@ exports[`getVariants 1`] = `
91859191
"selectors": [Function],
91869192
"values": [],
91879193
},
9194+
{
9195+
"hasDash": true,
9196+
"isArbitrary": false,
9197+
"name": "pointer-none",
9198+
"selectors": [Function],
9199+
"values": [],
9200+
},
9201+
{
9202+
"hasDash": true,
9203+
"isArbitrary": false,
9204+
"name": "pointer-coarse",
9205+
"selectors": [Function],
9206+
"values": [],
9207+
},
9208+
{
9209+
"hasDash": true,
9210+
"isArbitrary": false,
9211+
"name": "pointer-fine",
9212+
"selectors": [Function],
9213+
"values": [],
9214+
},
9215+
{
9216+
"hasDash": true,
9217+
"isArbitrary": false,
9218+
"name": "any-pointer-none",
9219+
"selectors": [Function],
9220+
"values": [],
9221+
},
9222+
{
9223+
"hasDash": true,
9224+
"isArbitrary": false,
9225+
"name": "any-pointer-coarse",
9226+
"selectors": [Function],
9227+
"values": [],
9228+
},
9229+
{
9230+
"hasDash": true,
9231+
"isArbitrary": false,
9232+
"name": "any-pointer-fine",
9233+
"selectors": [Function],
9234+
"values": [],
9235+
},
91889236
{
91899237
"hasDash": true,
91909238
"isArbitrary": false,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const enableDetailsContent = process.env.FEATURES_ENV !== 'stable'
22
export const enableInvertedColors = process.env.FEATURES_ENV !== 'stable'
3+
export const enablePointerVariants = process.env.FEATURES_ENV !== 'stable'
34
export const enableScripting = process.env.FEATURES_ENV !== 'stable'
45
export const enableUserValid = process.env.FEATURES_ENV !== 'stable'
56
export const enableWrapAnywhere = process.env.FEATURES_ENV !== 'stable'

packages/tailwindcss/src/variants.test.ts

+60
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,66 @@ test('inverted-colors', async () => {
19191919
`)
19201920
})
19211921

1922+
test('pointer-none', async () => {
1923+
expect(await run(['pointer-none:flex'])).toMatchInlineSnapshot(`
1924+
"@media (pointer: none) {
1925+
.pointer-none\\:flex {
1926+
display: flex;
1927+
}
1928+
}"
1929+
`)
1930+
})
1931+
1932+
test('pointer-coarse', async () => {
1933+
expect(await run(['pointer-coarse:flex'])).toMatchInlineSnapshot(`
1934+
"@media (pointer: coarse) {
1935+
.pointer-coarse\\:flex {
1936+
display: flex;
1937+
}
1938+
}"
1939+
`)
1940+
})
1941+
1942+
test('pointer-fine', async () => {
1943+
expect(await run(['pointer-fine:flex'])).toMatchInlineSnapshot(`
1944+
"@media (pointer: fine) {
1945+
.pointer-fine\\:flex {
1946+
display: flex;
1947+
}
1948+
}"
1949+
`)
1950+
})
1951+
1952+
test('any-pointer-none', async () => {
1953+
expect(await run(['any-pointer-none:flex'])).toMatchInlineSnapshot(`
1954+
"@media (any-pointer: none) {
1955+
.any-pointer-none\\:flex {
1956+
display: flex;
1957+
}
1958+
}"
1959+
`)
1960+
})
1961+
1962+
test('any-pointer-coarse', async () => {
1963+
expect(await run(['any-pointer-coarse:flex'])).toMatchInlineSnapshot(`
1964+
"@media (any-pointer: coarse) {
1965+
.any-pointer-coarse\\:flex {
1966+
display: flex;
1967+
}
1968+
}"
1969+
`)
1970+
})
1971+
1972+
test('any-pointer-fine', async () => {
1973+
expect(await run(['any-pointer-fine:flex'])).toMatchInlineSnapshot(`
1974+
"@media (any-pointer: fine) {
1975+
.any-pointer-fine\\:flex {
1976+
display: flex;
1977+
}
1978+
}"
1979+
`)
1980+
})
1981+
19221982
test('scripting-initial', async () => {
19231983
expect(await run(['scripting-initial:flex'])).toMatchInlineSnapshot(`
19241984
"@media (scripting: initial-only) {

packages/tailwindcss/src/variants.ts

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { type Variant } from './candidate'
1515
import {
1616
enableDetailsContent,
1717
enableInvertedColors,
18+
enablePointerVariants,
1819
enableScripting,
1920
enableUserValid,
2021
} from './feature-flags'
@@ -1150,6 +1151,15 @@ export function createVariants(theme: Theme): Variants {
11501151
staticVariant('inverted-colors', ['@media (inverted-colors: inverted)'])
11511152
}
11521153

1154+
if (enablePointerVariants) {
1155+
staticVariant('pointer-none', ['@media (pointer: none)'])
1156+
staticVariant('pointer-coarse', ['@media (pointer: coarse)'])
1157+
staticVariant('pointer-fine', ['@media (pointer: fine)'])
1158+
staticVariant('any-pointer-none', ['@media (any-pointer: none)'])
1159+
staticVariant('any-pointer-coarse', ['@media (any-pointer: coarse)'])
1160+
staticVariant('any-pointer-fine', ['@media (any-pointer: fine)'])
1161+
}
1162+
11531163
if (enableScripting) {
11541164
staticVariant('scripting-initial', ['@media (scripting: initial-only)'])
11551165
staticVariant('scripting-none', ['@media (scripting: none)'])

0 commit comments

Comments
 (0)