@emotion/react: Support using theme props with `css` API
See original GitHub issueThe problem
Existing css
from @emotion/react
doesn’t support accessing theme props as such:
const mixin = css`
color: ${props => props.theme.colors.primary}
`'
Proposed solution
Please support it as it is helpful for React developers:
- Allow use cases in theme definitions, mixins, helpers, etc. where accessing theme props is required
- Users migrating to Emotion from Styled Components will be blocked by the lack of this feature
No specific solution from me but styled-components
is a good example.
Alternative solutions
N/A
Additional context
Similar issue: #801
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Theming - Emotion
Theming is included in the @emotion/react package. Add ThemeProvider to the top level of your app and access the theme with props.theme in...
Read more >How To Use Emotion for Styling in React | DigitalOcean
emotion provides a css prop that can accept nested selectors and media queries. It can support an object or a tagged template literal....
Read more >Reactjs — Emotion For Styling Components | by Avery Duffin
We can access theme anywhere within styled components or by using withTheme. After that the theme is just another prop passed into the...
Read more >Emotion in React - LogRocket Blog
Emotion is a high performance, flexible, and performant CSS-in-JS library. Emotion helps us to style our application in a faster way, with a ......
Read more >Accessing Material UI Theme Object in Emotion JS
Pass the Material UI Theme Object to Emotion's ThemeProvider · Emotion Styled Components - Access Theme from props · Emotion CSS String Styles...
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
You can also just refactor this to:
It would be nice if solution 2 didn’t have to write the type every time. Style-component library can be done.