question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC] Material-UI v5 🚀

See original GitHub issue

Introduction

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

#18018, #13394

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

#6115, #16947

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

#15561

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

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.

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.


Timing

I think that we can try the following:

  1. Deprecation preparation. (starts now)
  2. 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.
  3. Work on the above items, in whatever order is simpler, keep the same release schedule, once a week, with alpha first.
  4. 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:closed
  • Created 4 years ago
  • Reactions:517
  • Comments:92 (62 by maintainers)

github_iconTop GitHub Comments

53reactions
dmtrKovalenkocommented, Mar 8, 2020

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

// packages/design-system
export * from '@material-ui/core'

export const ThemeProvider = ({ ...props }) => 
  <ThemeProvider theme={ourCustomStyledMuiTheme()} /> 

// then in app code
import { Button } from '@my-project/design-system' 

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 😢

import { useButton } from '@material-ui/core'

const buttonProps = useButton()
export const Button = () => <button {...buttonProps} /> 

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.

export * from '@material-ui/core/unstyled'

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.

31reactions
popuguytheparrotcommented, Apr 14, 2020

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.

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

[RFC] Material-UI v5 🚀 · Issue #20012 - GitHub
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...
Read more >
Introducing MUI Core v5.0
You can find the initial RFC plan for v5 in issue #20012. A new brand. Material UI is now MUI! Head to the...
Read more >
Developers - [RFC] Material-UI v5 🚀 - - Bountysource
React components for faster and easier web development. Build your own design system, or start with Material Design. Talking with backend and fullstack...
Read more >
React | Material-UIの使い方(UIフレームワークで手軽に構築)
補足ですが、2021年にv5のリリースを予定しているようです。 [RFC] Material-UI v5 🚀 · Issue #20012 · mui-org/material-ui ...
Read more >
MUI (@MUI_hq) / Twitter
The unstable CSS variables API introduced in v5.10.10 solves this problem ✨. ... [RFC] Material You support implementation strategy in Material UI ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found