[typescript] Re-export Theme type in @material-ui/styles
See original GitHub issue- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Context 🔦
Currently, to use makeStyles with Theme, I’ll have to use 2 imports:
import { makeStyles } from '@material-ui/styles';
import { Theme } from '@material-ui/core';
const useStyles = makeStyles((theme: Theme) => ({
// ...
}));
I’d be great if I we can update the styles package so that it re-export the Theme type from core, because I tend to group similar components of material-ui into 1 import statement:
import { makeStyles, Theme } from '@material-ui/styles';
styles already uses Theme type from core, so I believe making a re-exports should not be a big problem.
Thank you.
Issue Analytics
- State:
- Created 4 years ago
- Comments:25 (21 by maintainers)
Top Results From Across the Web
[typescript] Re-export Theme type in @material-ui/styles #15536
We reexport the styles modules with a default theme from the core. No, you most likely don't need it.
Read more >How to use Material UI custom theme in React with Typescript
Material UI custom theme in React with Typescript v4->v5 migration guide. create separate file for declaration. theme.d.ts import { Theme, ...
Read more >Breaking changes in v5, part one: styles and themes - MUI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >Material UI custom theme and TypeScript - Dragosh Mocrii
We use a mapped type CustomTheme to take the possible properties and their value types from our actual theme object. And we use...
Read more >TypeScript and Material-Ui - Medium
My colleague had a TypeScript file for defining global color and font values, a material-ui theme module, and a material-ui styles file.
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 Free
Top 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

We should just drop the breaking change. I can see no benefit and from my experience the whole
@material-ui/stylesvs.@material-ui/core/stylesusage has only caused confusion.I’m not sure some vaguely planned feature is a good reason to introduce a breaking change.
We should just re-export the
ThemeProviderfrom@material-ui/stylesin@material-ui/core/styles. At this point I don’t think we should actually advertise@material-ui/stylesif people are using@material-ui/core. At least I don’t see the benefit of importing from@material-ui/styles. If there is one we should document it.