@@ -5,6 +5,10 @@ const colors = require('tailwindcss/colors')
5
5
const [ baseFontSize , { lineHeight : baseLineHeight } ] = defaultTheme . fontSize . base
6
6
const { spacing, borderWidth, borderRadius } = defaultTheme
7
7
8
+ function resolveColor ( color , opacityVariableName ) {
9
+ return color . replace ( '<alpha-value>' , `var(${ opacityVariableName } , 1)` )
10
+ }
11
+
8
12
const forms = plugin . withOptions ( function ( options = { strategy : undefined } ) {
9
13
return function ( { addBase, addComponents, theme } ) {
10
14
const strategy = options . strategy === undefined ? [ 'base' , 'class' ] : [ options . strategy ]
@@ -32,7 +36,10 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
32
36
styles : {
33
37
appearance : 'none' ,
34
38
'background-color' : '#fff' ,
35
- 'border-color' : theme ( 'colors.gray.500' , colors . gray [ 500 ] ) ,
39
+ 'border-color' : resolveColor (
40
+ theme ( 'colors.gray.500' , colors . gray [ 500 ] ) ,
41
+ '--tw-border-opacity'
42
+ ) ,
36
43
'border-width' : borderWidth [ 'DEFAULT' ] ,
37
44
'border-radius' : borderRadius . none ,
38
45
'padding-top' : spacing [ 2 ] ,
@@ -48,19 +55,25 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
48
55
'--tw-ring-inset' : 'var(--tw-empty,/*!*/ /*!*/)' ,
49
56
'--tw-ring-offset-width' : '0px' ,
50
57
'--tw-ring-offset-color' : '#fff' ,
51
- '--tw-ring-color' : theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
58
+ '--tw-ring-color' : resolveColor (
59
+ theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
60
+ '--tw-ring-opacity'
61
+ ) ,
52
62
'--tw-ring-offset-shadow' : `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)` ,
53
63
'--tw-ring-shadow' : `var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color)` ,
54
64
'box-shadow' : `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)` ,
55
- 'border-color' : theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
65
+ 'border-color' : resolveColor (
66
+ theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
67
+ '--tw-border-opacity'
68
+ ) ,
56
69
} ,
57
70
} ,
58
71
} ,
59
72
{
60
73
base : [ 'input::placeholder' , 'textarea::placeholder' ] ,
61
74
class : [ '.form-input::placeholder' , '.form-textarea::placeholder' ] ,
62
75
styles : {
63
- color : theme ( 'colors.gray.500' , colors . gray [ 500 ] ) ,
76
+ color : resolveColor ( theme ( 'colors.gray.500' , colors . gray [ 500 ] ) , '--tw-text-opacity' ) ,
64
77
opacity : '1' ,
65
78
} ,
66
79
} ,
@@ -117,9 +130,9 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
117
130
class : [ '.form-select' ] ,
118
131
styles : {
119
132
'background-image' : `url("${ svgToDataUri (
120
- `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"><path stroke="${ theme (
121
- 'colors.gray.500' ,
122
- colors . gray [ 500 ]
133
+ `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"><path stroke="${ resolveColor (
134
+ theme ( 'colors.gray.500' , colors . gray [ 500 ] ) ,
135
+ '--tw-stroke-opacity'
123
136
) } " stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M6 8l4 4 4-4"/></svg>`
124
137
) } ")`,
125
138
'background-position' : `right ${ spacing [ 2 ] } center` ,
@@ -155,9 +168,12 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
155
168
'flex-shrink' : '0' ,
156
169
height : spacing [ 4 ] ,
157
170
width : spacing [ 4 ] ,
158
- color : theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
171
+ color : resolveColor ( theme ( 'colors.blue.600' , colors . blue [ 600 ] ) , '--tw-text-opacity' ) ,
159
172
'background-color' : '#fff' ,
160
- 'border-color' : theme ( 'colors.gray.500' , colors . gray [ 500 ] ) ,
173
+ 'border-color' : resolveColor (
174
+ theme ( 'colors.gray.500' , colors . gray [ 500 ] ) ,
175
+ '--tw-border-opacity'
176
+ ) ,
161
177
'border-width' : borderWidth [ 'DEFAULT' ] ,
162
178
'--tw-shadow' : '0 0 #0000' ,
163
179
} ,
@@ -185,7 +201,10 @@ const forms = plugin.withOptions(function (options = { strategy: undefined }) {
185
201
'--tw-ring-inset' : 'var(--tw-empty,/*!*/ /*!*/)' ,
186
202
'--tw-ring-offset-width' : '2px' ,
187
203
'--tw-ring-offset-color' : '#fff' ,
188
- '--tw-ring-color' : theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
204
+ '--tw-ring-color' : resolveColor (
205
+ theme ( 'colors.blue.600' , colors . blue [ 600 ] ) ,
206
+ '--tw-ring-opacity'
207
+ ) ,
189
208
'--tw-ring-offset-shadow' : `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)` ,
190
209
'--tw-ring-shadow' : `var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)` ,
191
210
'box-shadow' : `var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)` ,
0 commit comments