File tree 6 files changed +64
-0
lines changed
6 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Added
11
+
12
+ - _ Experimental_ : Add ` user-valid ` and ` user-invalid ` variants ([ #12370 ] ( https://github.com/tailwindlabs/tailwindcss/pull/12370 ) )
13
+
10
14
### Fixed
11
15
12
16
- Export ` tailwindcss/lib/util/flattenColorPalette.js ` for backward compatibility ([ #16411 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16411 ) )
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ export default defineConfig({
11
11
} ,
12
12
define : {
13
13
'process.env.NODE_ENV' : '"production"' ,
14
+ 'process.env.FEATURES_ENV' : '"stable"' ,
14
15
} ,
15
16
} )
Original file line number Diff line number Diff line change @@ -8405,6 +8405,8 @@ exports[`getVariants 1`] = `
8405
8405
" required" ,
8406
8406
" valid" ,
8407
8407
" invalid" ,
8408
+ " user-valid" ,
8409
+ " user-invalid" ,
8408
8410
" in-range" ,
8409
8411
" out-of-range" ,
8410
8412
" read-only" ,
@@ -8474,6 +8476,8 @@ exports[`getVariants 1`] = `
8474
8476
" required" ,
8475
8477
" valid" ,
8476
8478
" invalid" ,
8479
+ " user-valid" ,
8480
+ " user-invalid" ,
8477
8481
" in-range" ,
8478
8482
" out-of-range" ,
8479
8483
" read-only" ,
@@ -8527,6 +8531,8 @@ exports[`getVariants 1`] = `
8527
8531
" required" ,
8528
8532
" valid" ,
8529
8533
" invalid" ,
8534
+ " user-valid" ,
8535
+ " user-invalid" ,
8530
8536
" in-range" ,
8531
8537
" out-of-range" ,
8532
8538
" read-only" ,
@@ -8754,6 +8760,20 @@ exports[`getVariants 1`] = `
8754
8760
" selectors" : [Function ],
8755
8761
" values" : [],
8756
8762
} ,
8763
+ {
8764
+ " hasDash" : true ,
8765
+ " isArbitrary" : false ,
8766
+ " name" : " user-valid" ,
8767
+ " selectors" : [Function ],
8768
+ " values" : [],
8769
+ } ,
8770
+ {
8771
+ " hasDash" : true ,
8772
+ " isArbitrary" : false ,
8773
+ " name" : " user-invalid" ,
8774
+ " selectors" : [Function ],
8775
+ " values" : [],
8776
+ } ,
8757
8777
{
8758
8778
" hasDash" : true ,
8759
8779
" isArbitrary" : false ,
@@ -8867,6 +8887,8 @@ exports[`getVariants 1`] = `
8867
8887
" required" ,
8868
8888
" valid" ,
8869
8889
" invalid" ,
8890
+ " user-valid" ,
8891
+ " user-invalid" ,
8870
8892
" in-range" ,
8871
8893
" out-of-range" ,
8872
8894
" read-only" ,
@@ -8920,6 +8942,8 @@ exports[`getVariants 1`] = `
8920
8942
" required" ,
8921
8943
" valid" ,
8922
8944
" invalid" ,
8945
+ " user-valid" ,
8946
+ " user-invalid" ,
8923
8947
" in-range" ,
8924
8948
" out-of-range" ,
8925
8949
" read-only" ,
Original file line number Diff line number Diff line change 1
1
export const enableRemoveUnusedThemeVariables = false
2
+
3
+ export const enableUserValid = process . env . FEATURES_ENV !== 'stable'
Original file line number Diff line number Diff line change @@ -325,6 +325,34 @@ test('invalid', async () => {
325
325
expect ( await run ( [ 'invalid/foo:flex' ] ) ) . toEqual ( '' )
326
326
} )
327
327
328
+ test ( 'user-valid' , async ( ) => {
329
+ expect ( await run ( [ 'user-valid:flex' , 'group-user-valid:flex' , 'peer-user-valid:flex' ] ) )
330
+ . toMatchInlineSnapshot ( `
331
+ ".group-user-valid\\:flex:is(:where(.group):user-valid *), .peer-user-valid\\:flex:is(:where(.peer):user-valid ~ *) {
332
+ display: flex;
333
+ }
334
+
335
+ .user-valid\\:flex:user-valid {
336
+ display: flex;
337
+ }"
338
+ ` )
339
+ expect ( await run ( [ 'user-valid/foo:flex' ] ) ) . toEqual ( '' )
340
+ } )
341
+
342
+ test ( 'user-invalid' , async ( ) => {
343
+ expect ( await run ( [ 'user-invalid:flex' , 'group-user-invalid:flex' , 'peer-user-invalid:flex' ] ) )
344
+ . toMatchInlineSnapshot ( `
345
+ ".group-user-invalid\\:flex:is(:where(.group):user-invalid *), .peer-user-invalid\\:flex:is(:where(.peer):user-invalid ~ *) {
346
+ display: flex;
347
+ }
348
+
349
+ .user-invalid\\:flex:user-invalid {
350
+ display: flex;
351
+ }"
352
+ ` )
353
+ expect ( await run ( [ 'invalid/foo:flex' ] ) ) . toEqual ( '' )
354
+ } )
355
+
328
356
test ( 'in-range' , async ( ) => {
329
357
expect ( await run ( [ 'in-range:flex' , 'group-in-range:flex' , 'peer-in-range:flex' ] ) )
330
358
. toMatchInlineSnapshot ( `
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
type StyleRule ,
13
13
} from './ast'
14
14
import { type Variant } from './candidate'
15
+ import { enableUserValid } from './feature-flags'
15
16
import type { Theme } from './theme'
16
17
import { compareBreakpoints } from './utils/compare-breakpoints'
17
18
import { DefaultMap } from './utils/default-map'
@@ -692,6 +693,10 @@ export function createVariants(theme: Theme): Variants {
692
693
staticVariant ( 'required' , [ '&:required' ] )
693
694
staticVariant ( 'valid' , [ '&:valid' ] )
694
695
staticVariant ( 'invalid' , [ '&:invalid' ] )
696
+ if ( enableUserValid ) {
697
+ staticVariant ( 'user-valid' , [ '&:user-valid' ] )
698
+ staticVariant ( 'user-invalid' , [ '&:user-invalid' ] )
699
+ }
695
700
staticVariant ( 'in-range' , [ '&:in-range' ] )
696
701
staticVariant ( 'out-of-range' , [ '&:out-of-range' ] )
697
702
staticVariant ( 'read-only' , [ '&:read-only' ] )
You can’t perform that action at this time.
0 commit comments