I want to use animation in my application but it requires @property function in SCSS:
@property --border-angle { syntax: "<angle>"; inherits: true; initial-value: 0turn; }
Is there a way to do this in a styled component?
The complete code of the animation is located at: https://codepen.io/shshaw/pen/RwJwJJx
Or how to rewrite this function so that it does not have to use the property
function?
As I tested, the code posted does seem to work with
styled-components
, although browser support for@property
still seems to be limited , for example it works on Chrome, but currently not on Firefox, so the gradient animation won't play on it.I tried creating an alternative version of the posted code without using
@property
and it also works on Firefox. If it helps, here's a demo: stackblitz (code included at the end of the answer).The code originally posted was tested using the following example: stackblitz (Firefox does not currently support gradient animations for
@property
).Below is an alternative version without
@property
for comparison, which uses pseudo-elements and adds childdiv
to recreate the animation instyled-components
.Live Demo: stackblitz (should also work for Firefox).
By the way,@property
is the newer standard CSS. For more background information on@property
, see MDN. p>