[styles] How to merge multiple styles?
See original GitHub issueMaterial-ui uses the classes object to pass custom styles to component. withStyles helps us process theming and merging our customizations with the top level styles. Material-ui uses common classnames such as root
in multiple components. This is how I understand it.
Often we have multiple components on a page and I don’t understand what the best way is to use withStyles
in this context if I for instance want to adjust the root
style for multiple components?
- [x ] This is a v1.x issue (v0.x is no longer maintained).
- [ x] I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
Would it be possible to comment on the strategy that you suggest we use for this case and possibly add documentation?
Current Behavior
There is no documentation on this topic.
Your Environment
Tech | Version |
---|---|
Material-UI | v1.0.0 |
React | 16.3 |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:26 (14 by maintainers)
Top Results From Across the Web
How to combine multiple inline style objects? - reactjs
We have used ES6 Spread operator to combine two styles. You can also use Object.assign() as well for the same purpose.
Read more >How to merge multiple inline style objects ? - GeeksforGeeks
Multiple inline styles can be merged in two ways both the ways are described below: Method 1- Using Spread operator: The … operator...
Read more >Combining multiple styles in React Native | Laska Blog
In regular React, you will have to use Object.assign() or the spread operator to combine two styles. const styles = { square: { ......
Read more >[styles] How to merge multiple styles? · Issue #11517 - GitHub
withStyles helps us process theming and merging our customizations with the top level styles. Material-ui uses common classnames such as root in ...
Read more >Combine Layer Styles | Photoshop Training Channel
If you open the Layer Styles Panel (Window > Styles), you can apply any of the styles ... You can also combine two...
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
I made a utility to make this a lot easier:
And I use like this:
Unless I’m mistaken, I would have thought
withStyles
would have already worked with multiple styles out of the box, but if not, it would be cool to see an official wrapper like the one above.I recently ran into this problem when using
withStyles
, I was able to get around it with the following