[RFC] Second design system and theme structure #29024
Replies: 15 comments 32 replies
-
Could you please elaborate on what wasn't possible before using JavaScript? Shouldn't you be able to accept a |
Beta Was this translation helpful? Give feedback.
-
I personally don't resonate with the solution or the change proposed. I mean, I don't see how it solve the root problem (forcing developers to learn something in this context):
<Button startIcon={<SomeIcon sx={{ '&&': { fontSize: '24px' } }} />}>Button</Button> I think that using the React context, with an inversion of who owns the style (the icon, not the button) would solve the root pain. But in some cases, it might be overkill or seen as a leaky abstraction. |
Beta Was this translation helpful? Give feedback.
-
I'm really concerned by this. We're all here to make great user experiences. We can't do that without devs or designers - so great job working to make the lives of your customers better - but please don't forget that our customers are the end goal here; are the true consumers of MUI, and how we devs and designers will ultimately choose which library to use. |
Beta Was this translation helpful? Give feedback.
-
This looks really good. I'm glad that you're thinking about how theming would work nice and early, since that's such a big part of what makes MUI awsome. I can't wait to see the post about what the actual design will look like (so exciting!). One thing I'm curious about is whether or not joy will support using forms of shape other than just roundness. Material claims to support using angled corners, but I've never seen a real app using them. In my opinion, if joy does support other forms of shape it will really stand out among the crowd of design systems which currently don't have too much uniqueness. I would also love to be included in the feedback group. You can contact me here on github, on twitter (@edazpotato), and on discord (Edaz#5671). |
Beta Was this translation helpful? Give feedback.
-
I'm really looking forward to this new design system. I originally thought it will more like a new theme, but it seems that it is a complete overhaul. I'm wondering are you planning to move some of the designs (e.g. perfect dark mode, CSS variables) back to |
Beta Was this translation helpful? Give feedback.
-
Some feedback from an implementation perspective. ColorColor contrast is a big gap in MUI5 today. For example, there are no precomputed values for primary color variants with minimum WCAG contrast against white and black. As such, it's hard to build safe, performant components that work well with any MUI theme. Most modern design systems address this either in their descriptive tokens, or in their semantic tokens; I think you might need to pick one approach up front to achieve your stated aims for themes and color schemes.
I'm hoping you can find a good general purpose solution that will allow us to build hundreds of components that can work dependably with hundreds of very different themes. It seems like you're on the right track, but I feel like you might need more than an additional TypographyI'd love to see a more modern set of semantic variants.
And this last part probably goes without saying, but hopefully we can get built-in type sizes, line heights, and gutters that are actually usable out of the box! There's a good reason the MUI website overrides all of the MUI5 typographic defaults, and I'm sure most end users are doing the same. |
Beta Was this translation helpful? Give feedback.
-
hello, please can someone point me to the current documentation of joy? |
Beta Was this translation helpful? Give feedback.
-
Following the release of Joy, are there any plans or discussions around the support of Material 3 design system updates? |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm also looking for an ios like theming in MUI, or similar. I like joy but it's not really what I want. Anyone has his own custom UI? |
Beta Was this translation helpful? Give feedback.
-
Is there release planning for Joy UI 5.0.0-stable? |
Beta Was this translation helpful? Give feedback.
-
Are there any plans to auto-generate a palette based on a baseline color, similar to how Material generates |
Beta Was this translation helpful? Give feedback.
-
I have read all the manifest and I really like idea behind it. A more flexible and more Joyfully design can be something great, I would really like to contribute to it in any way, let me know if and how can I do it! |
Beta Was this translation helpful? Give feedback.
-
Is this the right place to ask if you have on the agenda making switching from Material-UI towards Joy simple? |
Beta Was this translation helpful? Give feedback.
-
Can I ask for a little more info regarding the warning about a development pause here: https://mui.com/joy-ui/getting-started/#introduction We are early in a project and will definitely be using Which of these is true:
Thanks for any guidance! |
Beta Was this translation helpful? Give feedback.
-
Introduction
We've mentioned in the v5 release blog post, a previous GitHub discussion, and on some issues here and there, that we were planning to develop a second design system. Instead of being a second theme of
@mui/material
, we concluded that it should rather be an actual design system, guided by a specific design language. One of the main benefits of thinking of it as a design system is that it can be a stand-alone product, with different default values, and therefore in its own package. Our main purpose with this is to expand the MUI audience – developers that appreciate the level of quality the library delivers but are tired of Material Design. We'll also use this opportunity to experiment with improvements and ideas that are a bit too risky/heavy to initially do on the@mui/material
package. We're definitely focusing on having a great visual design out of the box plus powerful customizability features so you can make it our own.It will be built on top of our developing unstyled components - which will also be very convenient since it's an opportunity to stress-test both packages at the same time. We hope to create a feedback loop that increases the speed of evolution of both. We're aiming at having a similar set of components compared to the
@mui/material
(though not all available on the first release).We've been using a codename for it, which is Joy (it's one option for its definitive name, let us know your thoughts on it too!). This is the first look at the initial work on its theme structure. But before diving into it, let me state what the objectives and non-objectives of this write-up are, so that we can have a more assertive discussion and focus on what we have so far:
Objectives
This discussion is meant mainly to get early feedback on the default theme structure and some ideas about the implementation. We'll also share thoughts (and early prototypes) about how to customize and extend it.
Non-objectives
We do not expect to discuss the presented content in detail, such as an API specification, for example. There's also no definition around the design direction as of now, so we won't be presenting any values for the properties of the theme nor talking about visual design as a whole.
If you are ready, let's dive in.
Rethinking the Theme
Customizability will be a huge part of Joy. Even though we're focusing on having sensible and opinionated defaults that act as a great starting point for your projects, we'll still optimize it for extensive customizability. To do so, we have been studying ways to add improvements to the current theming approach in
@mui/material
v5. We'll first introduce them on Joy to get early feedback and iterate until they are solid enough, so later on we can bring them back to the@mui/material
as well. Among them are:1. Theme & Color schemes definition
Sometimes, we use the word theme referring to the whole design language (specific values for each styling property) of an application (Material Design, iOS, Microsoft's Fluent, etc). Other times, we use theme referring only to the color scheme currently selected (light or dark). This can get confusing especially if you have an API where, on your ThemeProvider component, you pass to the
theme
prop alightTheme
ordarkTheme
value. Most often, this means that only colors are changing, all other properties remain intact.To improve on that, we're thinking of separating both concepts as it seems way more intuitive when dealing with colors. For example, you could have a theme called
MyCompanyTheme
which is comprised of specific values for each styling property. This theme can have many color schemes: light, dark, true dark, comfort, aqua, you name it. You'd define the different sets of palettes at the beginning of the theme. We'll talk about what the code would look like in the Unlimited color schemes section.This picture above illustrates the terms
design system
,theme
, andcolorSchemes
. This does not mean that Joy will provide a Material or iOS Theme by default.2. Adopting CSS variables
CSS variables will play an important role in Joy. This allows for building APIs that provide a much better customization experience and with a high percentage of browsers supporting it already, we are confident to bring it in. Some highlights of things we can do with it:
2.1. Perfect dark mode
The flashy dark mode problem is one we've been aware of for some time now. With CSS variables, we can create a stylesheet that contains all of the color schemes at build time and then pick the right color when a user enter the website. The picture below shows the high-level flow of how perfect dark mode can be achieved.
To understand this in more detail, check the dedicated RFC.
2.2. Component customization via variables
As we've said, Joy components will be built on top of the unstyled ones. To visualize how CSS variables actually provide a better customization experience, let's use one of the unstyled components already available: the switch. A switch basically has two parts: the track and the thumb.
Let's say we want to do something basic such as reducing the size of the thumb to be a little smaller. On
@mui/material
v5 this is how we'd normally do that:Unfortunately, the result is not really that good. Only changing the thumb size actually messes up its positioning and makes the overall component disproportionate. To fix that, we'd also have to change the track width and fix the position. But with CSS variables, we can compose the styling of each part of the component so they actually change accordingly - or synchronized, if you will. We couldn't do that before using JavaScript. Here's a proof of concept using CSS variables to compose the Switch component. You can play around with the properties values in the panel. You'll see that as you change one, the others follow.
Screen.Recording.2564-10-08.at.15.26.29.mov
We also used this POC to experiment with having multiple color schemes. But we're going to dive more into this below. If you use this Switch and wanted to customize it, you could do it by just changing the values for some of its variables (basically, in code, what is happening on the proof of concept GUI):
2.3. Adaptive component
A very common example is Icon. This component can be placed inside other components such as Button, Typography, ListItem, Menu, etc. To make it look great inside these components, the parent component needs to control the styles of the icon.
@mui/material
is using CSS specificity to do that. Here is an example of the Material Button:This isn't intuitive when it comes to customization. Without looking at the code, you would expect this to work:
Unfortunately, it doesn't because the
size="large"
orsx
props can't beat the CSS specificity coming from theButton
. To achieve it, you have to increase the specificity higher than the Button with this nasty code:This customization issue applies to other components as well, not just Icon.
CSS variables are very useful to create a component that can adapt to the parent and also allow customization from developer without creating nested specificity. Take the Icon as an example, Joy icons can looks like this:
By default, Icon's size will be
24px
because there is no variable--svg-size
declared at the upper scope. Now, the Button can control the icon size by declaring the variable.The customization works without CSS specificity 🎉 because the icon will use the nearest variable which is the one on the icon (
30px
)Here is a POC with more parent components using this approach.
2.4. Improved debugging experience
The CSS variables help developers and also designers to understand the token structure of a given element without even touching the codebase. It's way easier to read and to play around with values to reach the desired design.
Screen.Recording.2564-10-08.at.13.15.06.mov
2.5. Side benefits
From the POC, we found that CSS variables provide some side benefits that we get for free!
Slight performance improvement
In the current approach used by
@mui/material
, toggling between modes causes the whole application to re-render and recalculate the styles (className
change) so that they reflect the change on the screen. This process could take around 100-300ms but it ultimately depends on the number of components on the page. With the use of CSS variables, the processing time drops significantly because theclassName
doesn't regenerate* (the component still re-renders though). For more details about this topic, check out this blog post from Kent C Dodds.Here is a quick benchmark between
@mui/material
v5 and the POC version. We profiled the rendering time versusx
number of Switches when toggling between light & dark mode.The result shows that the CSS variables approach is significantly more performant than the current implementation in
@mui/material
. Here are the links that you can compare by yourself.@mui/material
SwitchVariable Reference
It is quite common to want to refer to other variables when defining a theme. Take this as example in
@mui/material
v5. The button color should use thepalette.primary.main
. To make this value reusable, we'd need to abstract theprimary.main
color to a variable:But with CSS variables, you can just refer to a variable via
var(--_{variable-name}_)
. This is the native syntax for using another variable in CSS:Works well with other styling methods
There is no limit If you need to use other methods for styling. For example, you can use a pure CSS stylesheet and refer to the variables generated by MUI:
3. The default theme structure
When looking for opportunities we could bring to the Joy theme structure, in comparison to the Material default, we noticed that it could benefit from the use of more low-level tokens, as this enforces even more consistency in the components while providing a set of opinionated values. "Low-level" implies that we'll have different layers of abstraction for given properties of the theme. A lower level token would be descriptive, holding the hard value of a given property and a high level would be semantic, holding indication info for how to use it. There will be instances where it's good to have it and others were not necessarily. We'll dive into the examples but keep in mind that this is all regarding the default structure - what comes out of the box for you. If these don't make sense to you, you'll be able to change them to fit whatever structure you wish.
3.1. Colors
Colors are probably the most illustrative example of the separation between descriptive and semantic tokens. To start, we'd have colors declared descriptively in a 50 to 900 value range. For example:
On the semantic side of things, we'd have the following structure:
Instead of having primary and secondary, which can cause confusion as to where to use which, we'd have instead only a brand color, the one that is the defining color for your product and company. Also, instead of having a light, main and dark value for each color, we'd have only one that defines each semantic variant:
3.2. Typography
Similar to colors, the idea is to have every low-level property defined in a descriptive way and then use them for semantic variations. The descriptive values structure:
And the semantic value structure, which directly consumes the descriptive tokens:
You'll notice that we're also using an
xs
toxl6
scale for font sizes. This is mainly to give a broad range of choices but constrained into a sufficient set of sizes that match one another. We'd also have a different (compared to the Material Design) set of semantic variants. There'd be one to hold each font size variant. We're still discussing these specifically but the current list is this:3.3. Shadow
We're planning on having only 4 levels of shadow, ranging from extra small to large. In addition, since shadow can have multiple layers, we plan to add the
ring
property for more convenient customization. The ring property acts as an inner shadow to make an element stand out from the rest. We are still working on the conclusion about making it visible/invisible in the default theme.3.4. Shape properties
We're also planning on tokenizing properties that are usually applied to shapes (your everyday
div
or<Box>
) to enforce consistency. The idea is to have extra-small to extra-large scale for them:3.5. Other properties
There were some properties that didn't need to be changed from Material Design, we believe them to be good enough already:
4. Unlimited color schemes
Light and dark will be built-in color schemes but really there won't be any limitation whatsoever to adding more custom ones. On the Switch demo mentioned above, there's already a proof of concept of this working.
Next steps
We hope that with this write-up we can gather as much feedback as we can to refine the overall idea and to start development with a clearer design in mind. As the development of the unstyled component progresses (you can help out with that!), we'll be getting them into Joy. Meanwhile, we're also evolving with designs explorations.
Closed feedback group
For this project, we're considering forming a closed group of contributors willing to test Joy and provide quick feedback. We're aiming to have the first iteration, with the first set of components, available in this quarter, so the folks in it would be of immense help to achieve this deadline. There's a comment in this discussion where you can leave a "hey! I'm interested in being a part of the feedback group" message as a thread. Let us know ways to contact you as well. We appreciate anyone that is available to help! :)
Other discussion about Joy
Beta Was this translation helpful? Give feedback.
All reactions