@@ -11,6 +11,7 @@ import isPlainObject from './util/isPlainObject'
1111import transformThemeValue from './util/transformThemeValue'
1212import { version as tailwindVersion } from '../package.json'
1313import log from './util/log'
14+ import { formatBoxShadowValue , parseBoxShadowValue } from './util/parseBoxShadowValue'
1415
1516export let variantPlugins = {
1617 pseudoElementVariants : ( { addVariant } ) => {
@@ -1774,6 +1775,7 @@ export let corePlugins = {
17741775 '--tw-ring-offset-shadow' : '0 0 #0000' ,
17751776 '--tw-ring-shadow' : '0 0 #0000' ,
17761777 '--tw-shadow' : '0 0 #0000' ,
1778+ '--tw-shadow-colored' : '0 0 #0000' ,
17771779 } ,
17781780 } )
17791781
@@ -1782,18 +1784,43 @@ export let corePlugins = {
17821784 shadow : ( value ) => {
17831785 value = transformValue ( value )
17841786
1787+ let ast = parseBoxShadowValue ( value )
1788+ for ( let shadow of ast ) {
1789+ // Don't override color if the whole shadow is a variable
1790+ if ( ! shadow . valid ) {
1791+ continue
1792+ }
1793+
1794+ shadow . color = 'var(--tw-shadow-color)'
1795+ }
1796+
17851797 return {
17861798 '@defaults box-shadow' : { } ,
17871799 '--tw-shadow' : value === 'none' ? '0 0 #0000' : value ,
1800+ '--tw-shadow-colored' : value === 'none' ? '0 0 #0000' : formatBoxShadowValue ( ast ) ,
17881801 'box-shadow' : defaultBoxShadow ,
17891802 }
17901803 } ,
17911804 } ,
1792- { values : theme ( 'boxShadow' ) }
1805+ { values : theme ( 'boxShadow' ) , type : [ 'shadow' ] }
17931806 )
17941807 }
17951808 } ) ( ) ,
17961809
1810+ boxShadowColor : ( { matchUtilities, theme } ) => {
1811+ matchUtilities (
1812+ {
1813+ shadow : ( value ) => {
1814+ return {
1815+ '--tw-shadow-color' : toColorValue ( value ) ,
1816+ '--tw-shadow' : 'var(--tw-shadow-colored)' ,
1817+ }
1818+ } ,
1819+ } ,
1820+ { values : flattenColorPalette ( theme ( 'boxShadowColor' ) ) , type : [ 'color' ] }
1821+ )
1822+ } ,
1823+
17971824 outlineStyle : ( { addUtilities } ) => {
17981825 addUtilities ( {
17991826 '.outline-none' : {
@@ -1844,6 +1871,7 @@ export let corePlugins = {
18441871 '--tw-ring-offset-shadow' : '0 0 #0000' ,
18451872 '--tw-ring-shadow' : '0 0 #0000' ,
18461873 '--tw-shadow' : '0 0 #0000' ,
1874+ '--tw-shadow-colored' : '0 0 #0000' ,
18471875 } ,
18481876 } )
18491877
0 commit comments