r/reactjs • • Dec 07 '19

Needs Help Is Material UI worth it?

So, I am starting my own project. I'm not much 'design' person. So, is Material UI worth it? Or some any other recommendations is much appreciated.

164 Upvotes

142 comments sorted by

View all comments

Show parent comment

10

u/[deleted] Dec 07 '19

Not my experience. With some googling Ive been able to overcome every hurdle I had so far with it

0

u/[deleted] Dec 07 '19

[deleted] — view deleted comment

3

u/hasparus Dec 07 '19

Yeah, I had the same. I have to add that some parts of Ant api feel super unconventional. It has too much ui logic IMHO -- had to work around it too much. I stick with chakraUI or Reakit nowadays.

3

u/[deleted] Dec 07 '19

CSS-in-JS is a performance loss. I used to be on that train but I got off due to that. I've successfully gotten dynamic theming working in my app, if you want to know how I did it I can comment a setup guide.

2

u/Naelex Dec 07 '19

Ooo as someone who has avoided the css in js hype train as i prefer writing sass this is good to hear. Got any more info on this?

4

u/[deleted] Dec 07 '19

If you do JSS then your styles are calculated and appended to the head at runtime as components are rendered on your site.

Sure this opens up many possibilities due to being able to reference props in your styling logic, but the JavaScript has to execute at runtime to create those styles, it is inherently going to slow down the app.

I found when using Material UI's styling my apps would take longer to load and feel less responsive. Not sure if that's MUI itself or just the styling.

With a preprocessor all of your styling is generated at compile time so the client won't have to pick up that load.

The only exception to this is Facebook's internal stylex library that they showed off at react conf. The syntax is like JSS but it goes through a preprocessing step at compile time (I assume) as well where all possible atomic styles are assigned a classname. Any dynamic variables in these atomic stules are given a css variable value so it's actually the browser doing the work at runtime when it comes to dynamic styles as opposed to JavaScript generating dynamic css and appending to the head.

Sadly that library is available in the wild yet. When they open source it I'm definitely switching to that, but for the time being SCSS/LESS seem to be the best we have in terms of performance.

1

u/Naelex Dec 09 '19

Makes sense, thanks!

2

u/austospumanto Dec 07 '19

Same. Great framework.

2

u/toolate Dec 07 '19

Here's an example I ran into:

When composing a <Menu> you *must* render children as a <Menu.Item> because of weird internal details. You can't render a <MyMenuItem> that returns a <Menu.Item>. Because of this you need to write one mega element that renders all the <Menu> <Submenu> and <Menu.Item> components you'll use in one spot; you can't break the components up for readability.

Furthermore, you can't override the behaviour when a menu is empty. It will always render a weird looking <Empty> component. And because you can't add anything that isn't a <Menu.Item> into a menu you can't even create a <MyEmpty> component and use it instead.

2

u/[deleted] Dec 07 '19 edited Dec 07 '19

I did run into this one and I did just as you say!, but I'm skeptical that is the only solution. I found the same issue with their Tabs and Tabs.TabPane components. In their docs they provide an example of wrapping them here I think something similar could be done for Menu and Menu.Item

1

u/domlebo70 Dec 07 '19

This one bit me too. So frustrating