Creating keyframes using styled objects
See original GitHub issueHello, thank you for maintaining Styled Components.
I would like to echo the sentiment shared in this Spectrum thread: creating custom animations using styled objects. This is something I would like to use in styled-components.
Here is an example using styled objects with keyframes
, but requiring an interpolated string when consuming the animation: https://codesandbox.io/s/animation-objects-b6h6h
const animation = keyframes({
from: {
opacity: 0
},
to: {
opacity: 1
}
})
// Keyframes must be consumed as an interpolated string
const Component = styled.div`
animation: ${animation} 3s;
`
Please let me know if there’s anything I can do to assist.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Adding CSS Animations with Styled Components - Medium
Luckily, I learned that styled-components can incorporate animations! From the styled-components docs: CSS animations with @keyframes aren't ...
Read more >styled-components keyframes animations - a very short guide
To create a @keyframes animation and use it with styled-components the first thing you need to do is to import the keyframes helper....
Read more >How to use styled components in React in order to get ...
1 Answer 1 · You don't actually use the component created by styled-component . When you do · To animate the top property,...
Read more >CSS Animations with Styled Components - Mario Kandut
CSS animations with keyframes can be easily done with styled-components and the helper utility keyframes . The code is cleaner, not scattered ...
Read more >keyframes - CSS: Cascading Style Sheets - MDN Web Docs
To use keyframes, create a @keyframes rule with a name that is then used by the animation-name property to match an animation to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
By the way, this is how a template string (for the animation) and a style object for the rest can be used together: (forked from the example above): https://codesandbox.io/s/animation-objects-forked-cwwn4
Am I missing something or you simply can’t use keyframes in object style at all? https://codesandbox.io/s/animation-objects-forked-6ryu1