[styles] custom theme variables with makeStyles
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.
Expected Behavior 🤔
makeStyles have access to custom variables created in theme https://material-ui.com/customization/themes/#custom-variables
Current Behavior 😯
makeStyles cannot access custom variables created in theme
const useStyles = makeStyles(theme => {
console.log(theme); // no theme custom variables
return {
root: {
width: '100%',
},
};
});
Steps to Reproduce 🕹
Link:
https://codesandbox.io/s/ovjn13pvk9
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v3.6.0 |
Material-UI/styles | v3.0.0-alpha.1 |
React | 16.7.0-alpha.2 |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:9 (3 by maintainers)
Top Results From Across the Web
[styles] custom theme variables with makeStyles · Issue #13734
Expected Behavior makeStyles have access to custom variables created in theme ... [styles] custom theme variables with makeStyles #13734.
Read more >How to use 'theme' and 'props' in makeStyles? - Stack Overflow
makeStyles get the theme by params so you can create a styles.js for every component with a arrow function inside and calling from ......
Read more >[Solved]-Using custom theme in makeStyles-Reactjs
Your custom theme is applied in this line: <ThemeProvider theme={theme}> , and your makeStyles function is called before that.
Read more >Advanced (LEGACY) - MUI System
The makeStyles (hook generator) and withStyles (HOC) APIs allow the creation of multiple style rules per style sheet. Each style rule has its...
Read more >Customize Theme - Ant Design
In version 5.0, we provide a new way to customize themes. Different from the less and CSS variables of the 4.x version, with...
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
makeStyles
is theme agnostic. You actually have to provide a theme via@material-ui/styles/ThemeProvider
: https://codesandbox.io/s/zr1mjxxpq4Can’t find this ‘function as a parameter of makeStyles syntax’ in docs, I only see examples passing an object to
makeStyles
. Shouldn’t it be noted thatmakeStyles
also accepts a function that will receive the theme, or is it noted somewhere else?