It is not possible to animate background-color with linear gradient value with either renderprops nor the hooks
Does not work
<Spring
from={{ backgroundColor: 'linear-gradient(135deg, rgb(185, 198, 109) 0%, rgb(34, 48, 17) 100%)' }}
to={{ backgroundColor: 'linear-gradient(135deg, rgb(192, 199, 165) 0%, rgb(31, 44, 31) 100%)' }}>
{props => <div style={props}>hello</div>}
</Spring>
Works
<Spring
from={{ background: 'linear-gradient(135deg, rgb(185, 198, 109) 0%, rgb(34, 48, 17) 100%)' }}
to={{ background: 'linear-gradient(135deg, rgb(192, 199, 165) 0%, rgb(31, 44, 31) 100%)' }}>
{props => <div style={props}>hello</div>}
</Spring>
(A clear and concise description of what you expected to happen.)
(Please provide either a CodeSandbox demo or an example GitHub repo.)
react-spring v8.0.27react v16.10.1Please try with v9: npm install react-spring@next
If that doesn't work, create a sandbox for us to test with. Thanks 馃憤
It still didn't work with react-spring@next
heres is a codesandbox link
I also tried animating background property from linear gradient value to a normal rgba() and it also didnt work
@noushad-pp, could you elaborate more on what you expect to happen? I don't have any issues animating linear-gradient values for a background color.
@noushad-pp Your sandbox works for me.
I also tried animating background property from linear gradient value to a normal rgba() and it also didnt work
That's not expected to work
@aleclarson If you look at the codesandbox, the second div is completely white and thus its not animating
Oh, that's also expected. As this article says:
Because
<gradient>s belong to the<image>data type, they can only be used where<image>s can be used. For this reason,linear-gradient()won't work onbackground-colorand other properties that use the<color>data type.
Most helpful comment
Oh, that's also expected. As this article says: