-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[poc] Support a version of Material UI without CSS in JS #44407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mnajdova
wants to merge
87
commits into
mui:master
Choose a base branch
from
mnajdova:poc/styling-v8
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Netlify deploy previewBundle size reportBundle size will be reported once CircleCI build #832201 finishes. |
Member
…i into feat/mui-css-layer
Co-authored-by: Diego Andai <diego@mui.com> Signed-off-by: Siriwat K <siriwatkunaporn@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
PR: out-of-date
The pull request has merge conflicts and can't be merged.
scope: system
The system, the design tokens / styling foundations used across components. eg. @mui/system with MUI
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR serves as a proof of concept of how we can build Material UI components using plain CSS, but still allow CSS-in-JS users to use all of the previously available APIs, like
sxprop,styleOverridesetc if they want to. On the other hand, for users that care about performance or want to use plain CSS/Tailwind CSS for customisation, they don't have to pay any penalty of bundle size or performance that comes from using CSS-in-JS.The PR also includes the changes from #46001.
Example projects:
Initial benchmark:
I did few performance benchmarks and the results are promising. I am comparing the updated
Slidercomponent that is created using plain CSS with the previous one that uses Emotion. On top of it I am adding the same customization (using Emotion) as current users have. There are the results I am getting:Test case 1: Rendering 500 sliders without any customization
Emotion - commit time: 2.8s
Plain CSS - commit time: 0.9s (3.1 x faster)
Test case 2: Rendering 500 sliders using sx prop with one CSS property
Emotion - commit time: 2.8s
Plain CSS - commit time: 1.1s (2.54 x faster)
Test case 3: Rendering 500 sliders using a long sx prop (iOS Slider example)
Emotion - commit time: 3.3s
Plain CSS - 1.8 (1.83 x faster)
Conclusion: In the worst case scenario, the component was 1.8 times faster. The most common use-cases will likely lie somewhere between the Test case 2 and Test case 3, which is still a substantial improvement. For every component that don't need customisation, the gain is already huge (3 times faster). Again, this is a bit of an artificial example, that uses only one component as benchmark but we can already see the size of the impact.
Todos:
We can use the
theme.generateStyleSheets()for this, however, as the functions generates JS syntax stylesheet, I used this converter to convert it to string (very fast AI generated implementation). We can provide it as a util out of Material UI.createTheme)