question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating keyframes using styled objects

See original GitHub issue

Hello, 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:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pvarga-dnicommented, Nov 24, 2020

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

1reaction
Grsmtocommented, Aug 21, 2020

Am I missing something or you simply can’t use keyframes in object style at all? https://codesandbox.io/s/animation-objects-forked-6ryu1

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found