Typescript support for theme when using css prop
See original GitHub issueemotion
version: 10.0.6react
version: 16.8.0-alpha.1
Relevant code:
<span
css={theme => ({
fontWeight: theme.font.weight.light,
position: "absolute",
right: "8px",
top: "52%"
})}
>
What you did:
Created a theme using using the emotion-theming
package
What happened: No typescript support for the provided theme object.
Reproduction:
Problem description:
From the documentation, it appears the current typescript support allows you to define the theme object shape when using styled()
, but not when using the css prop. Currently (and as confirmed by the documentation), the object is typed as any
.
Suggested solution:
Not sure if possible, but hopefully provide some way of defining a theme type via typescript generics, even when using the css prop. It appears the type is hardcoded for the css prop to any
here
Issue Analytics
- State:
- Created 5 years ago
- Reactions:20
- Comments:18 (13 by maintainers)
Top Results From Across the Web
TypeScript - Emotion
When using our JSX factory, TypeScript only allows the css prop on components that accept a className prop. This is because @emotion/react resolves...
Read more >Theme with styled-components and Typescript - Medium
Theming in styled-components allows your app to support multiple design patterns within the same app. Imagine an amazing code editor with no ...
Read more >reactjs - Typescript props and theming with CSS Modules
The destructuring assignment on props uses theme (without the leading $ sign). Should be styles.theme instead based on the code here. – John ......
Read more >TypeScript - Theme UI
While most APIs in Theme UI should just work in TypeScript, there are a few advanced use cases which will differ slightly. This...
Read more >Themes within themes with React, TypeScript and Styled ...
Finally, typography is where we will set global typography rules for this theme. We can use Styled Components' css to export some set...
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
We have decided to include a Theme interface that can be augmented in userland. This also provided that theme to the css prop - it has been implemented in https://github.com/emotion-js/emotion/pull/1609 and will be released in the upcoming v11.
Any updates on this?