Accessing props.theme in a keyframes object
See original GitHub issueHey!
I would love to be able to access my theme in a keyframes object. I am making a div’s background-color cycle through the various brand colors, but currently seem to have to hard-code the hex values.
My use case is something like this:
import styled from 'styled-components';
import { keyframes } from 'styled-components';
const colorize = keyframes`
0% {
background-color: palevioletred;
}
100% {
background-color: papayawhip;
}
`;
const Wrapper = styled.div`
animation: ${colorize} 4s ease-in-out infinite;
`;
It would be great if I could write background-color: ${props => props.theme.brandColorOne};
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Accessing props/theme in keyframes · Issue #397 - GitHub
It was really hard to work out a way to access props in animation keyframes to make animations themeable. Eventually I came across...
Read more >How to pass props to keyframes in styled-component with react?
I have following code and I want to pass value of y from react component to moveVertically keyframe ...
Read more >Keyframes - Theme UI
To directly set animationName using object syntax, append .toString() to the animation variable. This workaround is not needed when using the variable inside...
Read more >Styled-Components - Pass Props / Theme to keyframes?
Coding example for the question Styled-Components - Pass Props / Theme to keyframes? ... import styled from 'styled-components'; import { keyframes } from ......
Read more >React Styled Components — Animation and Theming - Medium
We can theme by exporting using the ThemeProvider component. ... which takes the theme prop to get the styles from the baseTheme object....
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
Duplicate of https://github.com/styled-components/styled-components/issues/397
Usage: