Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBasic ThemeProvider examples do not work #20457
Comments
|
So I think the documentation I should be reading is https://material-ui.com/customization/theming/ however that isn't obvious when you end up on the styling section. Apparently I shouldn't have been reading the documentation on theming, instead I should have been looking at the documentation theming. The styling section is a natural place to end up immediately after reading the documentation on components as its the very next section down. It also tends to turn up in Google searches since I'm thinking styling (from css) and thus that is my search terms. After reading basic styling this naturally leads to the advanced styling page, where one immediately spots the heading titled "Theming". While there is a small notice box above the first example, it doesn't actually make much sense until you understand theming. Finally, on the first page of the theming overview, one of the first links for "Theme provider" is to the API section, taking directly back to styles section (just below the advanced section). So after reading the API section one is almost certainly going to then check the basic styling and advanced styling guides. |
|
@chilversc Thanks for the feedback, we had the same one in #20136 that we tried to fixed with a better warning message. A couple of options:
|
|
I think the issues here is to look at the flow (i.e. the order of the sections), and avoid having duplicate or similar titles (i.e. two different pages both called theming). The other thing that would really help is some sort of glossary or overview, because when it comes to theming and styles there's a lot of overlap and its hard to know what any of it means until you realise what the purpose of the different sections are. This is then compounded by the different options such as I think the main issue here is there's actually two separate discussions happening with in the same documentation set. The main documentation is all about Material UI, thus when reading the style section one is approaching it Material UI as the context. However, the advanced styles section is really discussing two things, the Material Styles library (without UI), and advanced usages of themes/styles within Material UI. If these sections were broken up it would be a lot simpler to describe (at the cost of some duplication). As in the Material UI documentation all the examples can include There could be a separate set of documentation for Material Styles that can then focus on how the underlying library works, and how it could be used independently of Material UI. I would then consider having the Style documentation under a completely separate set of pages with links between the projects. |
@chilversc Interesting, we have been wondering about going in this direction in the past, mainly influenced by how jQuery used to differentiate its different projects in the UI: I think that we could consider doing something similar with the "unstyled" effort. It's going to be an interesting discussion to have once we make progress with the actual implementation. How do we market it? How do we document it? Sorry, I'm going off track. So, back to v5, we aim to move Material-UI styles to third-parties: https://cssinjs.org/, https://styled-components.com/, and http://emotion.sh/. |
|
In the mean time, I think that warning needs to be a bit more prominent. Perhaps instead of an alert box it should be part of an introduction / read first section. I was thinking of something like this:
Though I do find it odd in a section that is supposed to be all about the import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';This doesn't help draw a distinction between what is provided by styles, and what is provided by core. Unfortunately, a lot of those examples are useful for both the styles library (stand-alone) and the core library, such as using hooks and higher order components. I can't see a way to avoid duplication of the examples while maintaining clear separation between styles and core. |
|
Just thought, might even be useful to include an example of what happens when you do get the wrong method in the section on "@material-ui/core/styles vs @material-ui/styles" mentioning some of the most common error messages you will get to aid with searching for the error.
|
|
I think that we can go with the proposal of @eps1lon, adding |


Current Behavior😯
The existing Theme Provider documentation is misleading. When following the first example there is no mention that the configuration is not actually valid for use with the standard Material UI components.
Expected Behavior🤔
I should be able to extend the example to start adding components such as
PaperandTable.Steps to Reproduce🕹
DeepChildcomponent in aPapercomponenttheme.shadowsis undefined.https://codesandbox.io/s/material-demo-xxzs3?file=/demo.js
Context🔦
I was getting started with using theme providers and they would seemingly break at random with obscure errors when I started using other components such as
Table. Each time I would dutifully remove all the code I'd added and go back to the basic example that was working and start adding code again.I repeated this several times before realising that the example doesn't actually work and you need to perform some other step though its not obvious what step that is. I've been left to assume that I need to use
createMuiThemefor all themes, even nested ones.