[RFC] Material-UI v5 🚀
See original GitHub issueIntroduction
Material-UI v4 was released 10 months ago, per our release schedule. It’s time to plan for v5. Our GitHub milestone has a due date for October 1st 2020, and while I doubt we will release in time, planning 6 months ahead seems relevant.
Developers made it clear in the past that they don’t enjoy breaking changes. This is feedback we took into consideration when designing our versioning strategy, and for each minor/patch releases. The result was to commit to a minimum of 1 year between each major release.
At the same time, the v0 to v1 upgrade was a major breaking change (a rewrite with a brand new API) and yet it was successful. I think that we should be willing (taking the risk) to make bold changes, as long as they fit in the direction we see the community going in the long term (with Material-UI empowering it).
Structural changes
1. Unstyled components
Similar to Angular Material CDK components (Component Development Kit) #6218.
In practice, it could be a new hook version of all the components, something we have started to experiment with the useAutocomplete
and usePagination
in the lab.
The problem:
- The React OSS component community is fragmented. You will find both standalone components for a specific problem, as well as and a growing number of component libraries, with a wide range of API consistency, a11y, bug density, performance, bundle size, quality, and support.
- Styling solution usage is fragmented. We can get a glimpse of this by looking at the CodeSandbox usage stats for the style interoperability page:
- plain css: 34%
- styled components: 30%
- global css: 18%
- css modules: 12%
- emotion: 5%
- Developers and designers use different design systems. Material Design doesn’t have a monopoly.
- How can we help with the unstyled story of notistack, raised by @iamhosseindhv?
Why this solution?:
- This will enable Material-UI to stay relevant in the long term. This is a cornerstone of our strapline. It will shift the developer’s perception, that Material-UI is, at its core, about providing material to build UIs.
React components for faster and easier web development. Build your own design system, or start with Material Design.
- Talking with backend and fullstack users, we know that they are craving for a single component store rather than having to deal with a wide range of dependencies. We could expect the same from front-end developers.
- This new “offering” should better resonate with front-end developers. We could expect to gain more and higher quality contributions from the front-end community thanks to this shift.
- Based of our current trust, usage, and exposure in the React community, we are well-positioned to gain usage with this new “offering”.
- Maintaining standalone components is rarely sustainable. I have seen too many projects left abandoned. But by aggregating them in Material-UI, it helps our flywheel. It can incentivize new maintainers to work on the OSS. It can also strengthen our current monetization channels and invest resources back into the OSS components.
- It’s important to support different style engines and design systems.
2. Full strict mode support
The problem:
- While developers can set up strict mode in their app to identify incorrect patterns, Material-UI prevents them from keeping this mode enable on a daily basis, as there would be too much noise in the console. We have, for example, disabled it for the Material-UI documentation.
Why this solution?
- It’s the future.
- It helps with the unstyled story.
3. Migrate to styled-components
The problem:
- We have left important issues related to our styling solution unhandled over the last few months: streaming, strict mode, performance, CSS template support, style functions, class name mismatch, etc.
- We need to support dynamic props, this is important for the features we want to implement on the components.
- JSS popularity didn’t stick with the front-end community.
Why this solution?
- A migration to styled-components is our most requested (upvoted) issue to date.
- We want to remove the need for the majority of developers to bundle two CSS-in-JS runtimes.
It could be interesting to provide a choice between different style engines. v5’s users would be able to replace @material-ui/styles with react-jss.
4. Enable the use of @material-ui/system’s props in the core components
The problem
- Naming things is hard.
- Indirections can be inefficient.
Why this solution?
This is mainly driven by the positive feedback Tailwind and styled-system have had recently in the community. I enjoy the pattern a lot for one-off layout problems. It’s frustrating that only the Box component supports it. I think that it should also cover #6140.
<Typography textAlign={{ xs: 'left', md: 'center' }} />
<Button mt={3}>
Regarding the implementation and final API, we could still reconsider the tradeoff (relying on global class names rather than style functions).
5. Allow the use of dynamic theme variants and colors
#15573 & #13875. Allow breakpoints customization #11649.
I was wondering about revamping the theme structure to match System-UI Theme Specification but we don’t see a clear win so far.
Material-UI’s theme structure, on its own, is a specification, the structure is set. Assuming that Material-UI aims to support a wide range of components (unstyled or not), matching this spec, not just Material Design, I fail to see a strong advantage a different constraint could yield.
On the cost side, using theme-specification would require to drop some of the features of our theme and require breaking changes. The benefit isn’t obvious, but it’s something to consider.
Regarding styled-system. I think that we should re-evaluate if we still need @material-ui/system.
Material Design
✅ Checklist
- [Checkbox] Make color=“primary” the default (#26002)
- [Paper] Dark mode brighening based on elevation #18309 (#25522)
- [Snackbar] Dark mode color #24438
- [Tabs] Improve color management #24286
- [Switch] Make color=“primary” the default (BC: #26182)
- [Radio] Make color=“primary” the default (BC #26180)
- [Tabs] Remove min-width media query #15824 (BC: #26458)
- [Select] Update to match the specification #18493 (BC: #26200)
- [Dialog] Flatten DialogTitle DOM structure #19696 (BC: #26323)
- ~[Button] Reduce the duration of the transition from 250ms to 200ms https://github.com/mui-org/material-ui/pull/24521#discussion_r562095317~ I don’t think this is worth doing now - edited by @siriwatknp
- ~[Autocomplete] Consistency with select #18136~ [move to v5.1]
- [AppBar] Improve the design #18308 (BC: #26545)
- [Checkbox][Switch] Remove dependency on IconButton #21503 (BC: #26460)
- [docs] Use the default theme #22112, https://github.com/mui-org/material-ui/issues/21040#issue-618679269
- [theme] Dark mode colors #18378
- ~Material Design states #10870~ deferred @siriwatknp
- ~[Tabs] Update to match the specification #15324~ deferred (can be workaround by css) @siriwatknp
- [theme] Improve the breakpoints values #21902
- [Menu] Remove MenuItem dependency on ListItem #21587
- [Slider] Update to match the spec #20153
- [IconButton] Update default size and add
large
#24045 - ~[Button] Update to match the spec #19664~ deferred @siriwatknp
Lab to core components
I think that we can aim to move the following components from the lab to the core:
✅ Components
- Alert (#22651)
- Autocomplete (#22715)
- AvatarGroup #18869 (#23121)
- Pagination (#22848)
- Rating (#22725)
- Skeleton (#22740)
- SpeedDial (finally!) (#22743)
- Toggle Button (#22784)
The only component I have would propose to handle later on is the TreeView. We still have a couple of important features to implement, and might need to change the API to ship these features. Once we do, we’ll start to get more adoption, so the more likely it is that developers will uncover root issues.
Supported browsers
While we plan to keep IE 11 support until v6, We will look into proposing different proposing entry points #18447. and if we can drop older browsers’ versions #15496.
Deprecations
✅ List of breaking changes we can introduce with a deprecation during v4.
- ~Drop createStyles (see https://github.com/mui-org/material-ui/issues/20012#issuecomment-752125358)~
- ~[Portal] Remove Portal
disablePortal
prop. Maybe we can implement the logic at the Portal component consumer level. https://github.com/mui-org/material-ui/pull/18692#issuecomment-562197612~ - [theme] Remove
theme.mixins.gutters
. I don’t believe we document them, nor are they used. (BC: #22109, Dep: #22245) - [theme] Rename theme
type
->mode
. While the spec use “schema”, saying “dark mode” seems to be more common, e.g https://css-tricks.com/dark-modes-with-css/. (BC: #22687, “Dep”: #22702 –adaptV4Theme()
) - [theme] Rename color helpers https://github.com/mui-org/material-ui/issues/13039#issuecomment-476020214. (BC: #22834, Dep: #22837)
- [test] Remove enzyme test helpers. They are legacy. It’s also a good opportunity to upgrade the documentation #17070. (BC: #21855, #21863, Dep: #24074)
- Remove the onX* transition props from Dialog, Snackbar, Menu & Popover, https://github.com/mui-org/material-ui/issues/17047#issuecomment-523549825. (Snackbar BC: #22107, Dep: #22206; Popover BC: #22184, Dep: #22202; Dialog BC: #22113, Dep: #22114; Menu BC: #22212, Dep: #22213)
- Remove RootRef, it relies on
ReactDOM.findDOMNode(component)
that is already deprecated. (BC: #21974, Dep: #24075) - [icons] Change default
fontSize
prop’s value: default -> medium, for consistency with the other components #14993. (BC: #23950, Dep: #23951) - [Accordion] Normalize focusVisible logic (BC: #22567, Dep: #24083)
- [Avatar] Rename variant circle -> circular for consistency #21964. (BC: #22015, Dep: #22090)
- [Badge] Rename overlap circle -> circular and rectangle -> rectangular for consistency #21964. (BC: #22050, Dep: #22076)
- [CircularProgress] Remove one variant. Kill the current
determinate
variant, renamestatic
=>determinate
. https://github.com/mui-org/material-ui/issues/7223#issuecomment-566536553. (BC: #22060, Dep: #22094) - [Collapse] Add orientation and horizontal support (BC: #20619, Dep: #24079)
- [Dialog] Remove withMobileDialog. #14992. We have already removed it from the documentation. (BC: #23202, Dep: #23570)
- [Dialog][Modal] Remove disableBackdropClick (BC: #23607, Dep: #24081)
- [Fab] Rename Fab round -> circular for consistency #21964. (BC: #21903, Dep: #24080)
- [Grid] Rename prop justify -> justifyContent to match system API. (BC: #21845, Dep: #24078)
- [GridList] Rename component to ImageList as more intuitive and better match the wording of the Material Design spec #14994. (BC: #22311, Dep: #22363)
- [GridList] Rename Tile to Item (BC: #22385, Dep: #22363)
- [GridList] Refactor using CSS grid & React context (BC: #22395, Dep: #22363)
- [GridList] Rename
spacing
prop togap
to align with the CSS attribute. (BC: #22395, Dep: #22363) - [GridList] Rename the GridList
cellHeight
prop torowHeight
. (BC: #22395, Dep: #22363) - [GridList] Rename the GridListItemBar
titlePosition
prop toposition
. (BC: #22395, Dep: #22363) - [Modal] Add support for onKeyDown and remove onEscapeKeyDown (BC: #23571, Dep: #24081)
- [Portal] Remove onRendered -> ref. context: https://github.com/mui-org/material-ui/pull/16262#discussion_r294750748. (BC: #22464, Dep: #24082)
- [TextareaAutosize] Rename rowsMax -> maxRows for consistency, (BC: #21873, Dep: #23530)
- [Table] Rename onChangeRowsPerPage -> onRowsPerPageChange, onChangePage -> onPageChange for consistency. It’s a good opportunity to mention this API design choice in the documentation: https://jaketrent.com/post/naming-event-handlers-react/#more-complicated-naming; (BC: #22900, Dep: #23789)
- [theme] Remove the
fade
color helper #13039. (BC: #25895) - [Button] Remove the
buttonRef
prop. (BC: #25896, Dep: #25897) - [Popover] Remove
getContentAnchorEl
prop. This method was present to implement a macOS native select like experience. It complicates the implementation of the Popover and could prevent us from moving #17353 forward. - [TextField] The
position
prop should be required inInputAdornment
. (BC: #25891, Dep: #25912) - [Button] Change LoadingButton prop pending to loading #21593 (BC: #25874)
- [SwitchBase] Remove second onChange argument: event.target.checked is enough. (BC: #25871)
- [theme] Remove the exported theme.typography.round helper. (BC: #25914, Dep: #25916)
- ~[theme] Remove legacy v4 deprecation
Object.defineProperty(spacing, 'unit', {
~ - ?[theme] Replace
theme.direction === 'rtl'
->theme.isRtl
. - [Table] Rename
padding="default"
->padding="normal"
(BC: #25924, Dep: #25990) - [theme] Remove
function width(key) { return values[key]; }
, it’s useless. (BC: #25918, Dep: #25993) - [theme] Rename createMuiTheme -> createTheme to match ThemeProvider’s theme prop. (BC: #25992, Dep: #26004)
- ~?[theme] Flatten colors to support CSS variables as theme option #12827~ later
For a list of committed breaking changes and associated deprecations, see: https://github.com/mui-org/material-ui/issues/22074
Breaking changes
Unlike the previous section, these are breaking changes we can’t gracefully warn against.
-
~? [AppBar] Change default position from fixed to static. What’s the most frequent AppBar position?~
-
~? Rotate 180° icons to only include one? Involve: TablePagination, Pagination or DatePicker~.
-
~[Slider] Fix the class names naming.
track
andrail
means the same thing.~ -
[Container] Revisit max-width values to be more useful #21902
-
[core] Only support node >= 10 https://github.com/mui-org/material-ui/pull/19301#issuecomment-575991456 (#22814)
-
[theme] Remove dead
palette.text.hint
key -
[theme] Always return value with ‘px’ unit in the spacing function breaking change enhancement #16205 (#22552)
-
[theme] Breakpoints down use interval. Same as https://github.com/ionic-team/ionic/blob/master/BREAKING.md#display-classe #13448 (#22695)
-
[Chip] Change variant default value #18914 (#22683)
-
[Divider] Use border instead of block content (#18965)
-
[Pagination] Rename round -> circular for consistency #21964. (#22009)
-
[Popper] Figure out what we do with popper.js, we have 4 options upgrade, remove it, rewrite it, fork it #19358 (#21761)
-
[Skeleton] Rename variant circle -> circular and rect -> rectangular for consistency #21964. (#22053)
-
[Slider] Custom tooltip ignores valueLabelFormat and valueLabelDisplay #17905.
-
[Snackbar] Change default position. Change the default position of the snackbar on desktop to bottom left. This will better be aligned to the behavior of material.io, Gmail, Google Keep, notistack, etc. (#21980)
-
[Stepper] Remove Paper component #18423 (#22564)
-
[Textfield] Change the default variant -> outlined. Per https://medium.com/@brianisrighthere/material-studies-text-fields-f029b3b38020. (#23503)
-
[CssBaseline] Apply body2 -> body1 #17100. (#24018)
-
[types] Remove deprecated
SimplifiedPropsOf
/Simplify
types. #24750 -
~[typescript] Only support TypeScript 3.8 and onwards. Omit was added in 3.5, can be removed from @material-ui/types.~
-
[Select] Change the default variat as TextField https://github.com/mui-org/material-ui/pull/24180#issuecomment-752773145. #24895
-
[core] Remove deprecated
innerRef
prop, forwardRef do the job now. (BC #26028) -
[Hidden] Remove component #19704. The CSS API can be replaced with the Box, the JS API can be replaced with useBreakpoint or useMediaQuery. (BC: #26135)
-
Remove withWidth, replace with useBreakpoint() #17350. (BC: #26136)
-
[theme] Remove MuiThemeProvider alias. ThemeProvider is enough. https://github.com/mui-org/material-ui/pull/22791/files#r499154080 (BC: #26171)
-
[Autocomplete] Rename the reasons for consistancy.
'create-option'
is not OK. It should be camelCase. (BC: #26172) -
~[Select] Replace <TextField select> with <SelectField /> #21782 (PR #26221)~ Do in the lab instead
-
[Autocomplete] Polish the pseudo-classes customization API #19692 (BC: #26181)
-
~[Grid] Remove the type exports, developers don’t need them. https://github.com/mui-org/material-ui/issues/19572#issuecomment-583070229 (BC: #26187)~ https://github.com/mui-org/material-ui/blob/9f3c45b1f7fbb7c2095b61c30a3e0659f21dd5cf/packages/material-ui/src/Grid/Grid.d.ts#L8
-
[Select] CSS API’s ‘selectMenu’ maps to the same element as ‘select’ #11646. (BC: #26186)
-
[Autocomplete]
getOptionSelected
is confusing, rename tooptionEqualValue
#24855 (BC: #26173) -
~Improve the color prop handling #13028~ [move to v5.1]
-
~[CssBaseline] Improve CSS reset, can we leverage any of https://hankchizljaw.com/wrote/a-modern-css-reset/, https://github.com/sindresorhus/modern-normalize/blob/master/modern-normalize.css~ deferred @siriwatknp.
-
Remove wrapper in
BottomNavigationAction
-
~ref attribute is not the root element #19613~ [move to v5.x]
Timing
I think that we can try the following:
- Deprecation preparation. (starts now)
- Create the
next
branch, publish the next versions under https://next.material-ui.com/ and the next npm tag. (April?). Stop all efforts on the v4.x version. Put the master branch (v4.x) in a low maintenance mode, only handle security fixes. - Work on the above items, in whatever order is simpler, keep the same release schedule, once a week, with alpha first.
- Once we have handled all the breaking changes and confidence with the architectural choices move to a beta stage. Once we are confident with the implemented features, start release candidates.
Current progress 109/109
Array.from(document.querySelectorAll('.contains-task-list')[2].children)
.concat(Array.from(document.querySelectorAll('.contains-task-list')[3].children))
.concat(Array.from(document.querySelectorAll('.contains-task-list')[1].children))
.concat(Array.from(document.querySelectorAll('.contains-task-list')[0].children))
.reduce((acc, item) => {
if (item.querySelector('input[type="checkbox"]:checked')) {
acc.done += 1;
}
acc.total += 1;
return acc;
}, { total: 0, done: 0 });
Issue Analytics
- State:
- Created 4 years ago
- Reactions:517
- Comments:92 (62 by maintainers)
Top GitHub Comments
Unstyled components
I think that providing hooks is not a really best solution for making custom design systems. I know that some companies using material-ui like
And this is a really powerful way to build custom design, based on best practices and documentation of material-ui. The main problem here is only bundlesize bloating. You have no way to remove from the bundle overridden css. Unstyled components can solve this problem just fine.
But the proposed solution with hooks will may them to write custom components, custom dom structure – that’s why I don’t think it will not become really popular.
Should it work something like this? This will make building design system overcomplicated and require everybody to rebuild html structure, which in its turn can break accessibility 😢
Proposal
I propose to provide an additional exported components but without any css. So they will be just empty html components with the logic. Thus any company will be able to handcraft custom design for provided components and use all the power of material-ui accessibility, types, documentation and so on.
How? For example, we can make a custom babel plugin that will, for example, remove all the css code from components and will leave only class names.
I’m Concerned for DX in Developer Tools. I would like to avoid such nesting without to the use of filters. For example, if this possible to change hoc withStyles to hook, and forward ref to hook. Fix Anonymous names.