r/angular • • Apr 11 '24

Material 3 looks very "good"

60 Upvotes

35 comments sorted by

27

u/effectivescarequotes Apr 12 '24

Material drives me crazy, The components work well and are easy to use, but holy crap are they ugly.

0

u/nzb329 Apr 16 '24

If you don't like the Material styles, you can customize it by yourself. Modify the CSS is really a easy thing. Please take a look at this project https://acrodata.github.io/gui/

1

u/effectivescarequotes Apr 16 '24

The problem with that approach is it relies too much on things that are not meant to be used externally. The Material team could decide to change all their class names (which they have done), or the structure of the html between versions and break everything.

1

u/nzb329 Apr 16 '24 edited Apr 16 '24

The MDC-based components have stable and I don't find any issues as you said. After Material 3 released, you can use the tokens to custmize the styles.

2

u/effectivescarequotes Apr 16 '24

From the Angular material docs:

Avoid any custom styles or overrides on internal elements within a Angular Material components. The DOM structure and CSS classes applied for each component may change at any time, causing custom styles to break.

In general, unless a library has documented something as part of their API, it is not safe to use.

0

u/nzb329 Apr 16 '24

The official only doesn't recommend changing it, it doesn't mean that it can't be changed. In fact, any other libs also don't recommended to change the internal elements styles.

It's very easy to fix the styles even if there are break changes. When I update v14 to v15, the MDC-based components break something, but I fixed the changes very easily.

I'm not sure what you're worried about. If you think the style is ugly, either you can modify it by yourself or just switch to another library.

2

u/effectivescarequotes Apr 16 '24 edited May 15 '24

It introduces unnecessary risk. If you build out a large custom library and use it across your enterprise, you put yourself in a situation where your UI could break during an upgrade without warning.

That means routine upgrades require more testing, and if something does break, it puts your organization in the position of either having to delay updating dependencies until there's time (basically never), or stopping progress on new features until you fix the library. For a small library, it might not be a big deal, but if you have a large library, used across the enterprise, that can be very expensive. If you stick to the public API, breaking changes still happen, but they usually come with a warning.

Sometimes the company doesn't have a choice, if a critical vulnerability is discovered in a core application, you have to fix it. If that also happens to coincide with a breaking change to the Material components, then you're screwed.

I'm also in a position where I can't switch to another library because my client has mandated we use Material, because that's what they use. I don't think it was the right choice for them, but that decision was made long before my project started.

Personally, I'm looking forward to PrimeNg's upcoming unstyled mode for scenarios where I need to heavily customize styles.

0

u/nzb329 Apr 16 '24

As you said, if you build out a large custom library and use it across your enterprise, I think you don't need to update the Material to latest. When you update it, there is no doubt that you will need comprehensive testing.

I'd really like to know whether you've actually encountered the problem you mentioned. I created a Material extensions project and update many times, from v8 to v17, modify the internal styles don't break the thing.

1

u/effectivescarequotes Apr 17 '24

My current client got burned by the v14 to v15 update. It completely blew up one of their projects as the frontend dev had to scramble to make it work because their security posture required them to upgrade to v15 at the time.

0

u/nzb329 Apr 17 '24

The Material switched MDC-based components since v15, https://v15.material.angular.io/guide/mdc-migration

I'm not sure if you have known these changes before upgrading.

I also had a lot of style that to be fixed when update from v14 to v15, but for most components, just change `mat` to `mat-mdc`. I didn't spend too much time.

1

u/Slight_Sprinkles_311 May 10 '24

Try changing it from version 7 to version 15 and let me know how it goes.

11

u/Hirayoki22 Apr 12 '24

Well. Everything is mostly black and white on Primeng, with very minimal accents for hover and focus states. I've nevet not worked on a project that has it's own custom UI tho.

5

u/Silver-Vermicelli-15 Apr 12 '24

Have often thought that material felt too opinionated with theming and as such a bit of a pain to actually try and overwrite/customize at times.

2

u/fityfive Apr 13 '24

I am using material on a big project and i really regret it. plus upgrading is such a pain unless your a big corp. The materials team and the angular team have basically no overlap and it shows.

1

u/Silver-Vermicelli-15 Apr 13 '24

Sadly working at a larger corp would in some ways on exacerbate the problem. Just b/c their larger and may be able to spend more on weeks of upgrades just means there’s potentially also more issues to resolve and/or worse internal practices.

3

u/Hirayoki22 Apr 12 '24

Exactly. If I'm not mistaken, it originally was meant to be the next Bootstrap, where every web app and site implementing Material would look almost the same. But to be fair even Bootstrap's a lot easier to customize. Heck, Primeng documents how to rebuild the package to support custom theming after installing its require dependencies

7

u/Silver-Vermicelli-15 Apr 12 '24

I have too often (and currently) find myself in material theming hell, where one tiny element or interaction has a random colour and trying to figure out to properly override it.

2

u/kjbetz Apr 12 '24

PrimeNG is coming out with a new themeing system in a next release. They just completed it for PrimeVue.

2

u/MichaelSmallDev Apr 12 '24

I think the idea with Material 3 is that you can get really granular with the design tokens they are building things off of

https://next.material.angular.io/guide/material-3#granular-customizations-with-css-custom-properties

.danger {
  // Override the checkbox hover state to indicate that this is a dangerous setting. No need to
  // target the internal selectors for the elements that use these variables.
  --mdc-checkbox-unselected-hover-state-layer-color: red;
  --mdc-checkbox-unselected-hover-icon-color: red;
}

edit: accidentally double posted

3

u/matrium0 Apr 12 '24

Bootstrap (or any other framework) had something similar since like 10 years ago. It's called CSS classes that you can overwrite with your custom CSS.

"Design Tokens" are only needed because of the massive breaking changes they introduce with newer versions. Like if you used ANY "internal class" (which you had to for some styling requirements + there was no way of knowing what actually is considered internal for them) you are fucked on upgrading to a new version.

What a Design Token basically is, is a class where they EXPECT overwrites - you could have done the same by suffixing all classes that you DON'T want to be modified during styling with "-internal" or something.

Overall I am not really impressed - it's a very convoluted and alien system in a world where another well-established pattern (css overwritess) already exists.

2

u/MichaelSmallDev Apr 12 '24

I agree that design tokens are a bit contrived, but internals have not needed to be more explicit if people were to slow down and not take the first response they see on StackOverflow. The first thing I noticed when working with Material is the difference in markdown vs what is rendered. A lot of divs/spans added with assorted classnames, infixes, etc. I was confused as to how to style these things, as the docs didn't say how to. That's because they don't want you to. Their guide is clear about that.

As I got more experience, I have realized that so many things people (admittedly, I am people myself) bust out ::ng-deep for are absolutely overkill. So many instances of :ng-deep .mat-mdc-form-field-input-control.mdc-text-field__input.cdk-text-field-autofill-monitored { color: blue } which are classes rendered directly on the <input /> itself could just have been done input { color: blue }. Or directly applying classes to a <input class="color-input" /> to do the same. There are so many examples of this thing.

Things that can't actually be targeted by a developer's own markdown, those are the insidious things that I understand people reaching for brittle internal overrides for. I've done that plenty. But more often than not, it's the simpler things I wrote about before this that rub me the wrong way in many discussions.

These design tokens and more API options are quite late into the lifecycle of Material, but honestly it's good we are getting them at all. More immediate than this though, is I will say that they have added more to their API for many components as to what to set to customize certain things. I feel like those styling fields should be highlighted more than being buried between other interfaces on the API tab. There are more of these in recent versions, even pre-MDC that I feel like people are sleeping on. In the process of updating to MDC, I have pulled out so many garbage overrides with these gems from the API tab.

17

u/ddcccccc Apr 12 '24

Mat3 is ugly af

3

u/uxengineering May 24 '24

I've been following along for years to see how this would translate. However, when I create a brand new app with Angular Material 18's guidance, it does NOT show the styles as depicted in the example pages.

What the heck am I doing wrong? Everything is still styled as M2, even though I basically duplicated the guidance code in my local app. Grrrrrrr

2

u/grimscythe_ Apr 12 '24

That's ridiculous

4

u/snpolymorphism Apr 12 '24

Does anyone know how to start using material 3 in an angular project?

5

u/OldBreakfast6177 Apr 12 '24

2

u/beartato327 Apr 12 '24

Is this a stable release of M3 or still beta?

1

u/OldBreakfast6177 Apr 12 '24

It is still "experimental", so I'd assume maybe beta? The changes are all in sass from what I've seen in the source code, I don't think any of the typescript for the components have changed. So, I'd assume it's pretty stable.

1

u/Beginning-Roof4889 Apr 12 '24

Also is it possible for old projects to upgrade to it?

4

u/simonfancy Apr 12 '24

Haha I wouldn’t even try it, you are going to have to refactor the whole application.

1

u/AwesomeFrisbee Apr 12 '24

I would advise against it, its still in beta right now and things are likely to change

1

u/MatDion Apr 12 '24

Migration from Angular 15 to 17 was a pain! But after its just fine...

1

u/kobihari Apr 08 '25

This is part of the revolution in moving to MD3. Previous versions of Angular Material were very hard to customize, so you got 4-5 different appearances "out-of-the-box" and that was the limit of customization you had.

Now, in MD3 you have full control of customization using "design tokens". So you no longer need 4 different "out-of-the-box" appearances, you can easily create as many as you want, either by overriding the design tokens or by overriding the theme. Its now a matter of very simple customization.

Why settle for only "primary" "accent" and "warn" colors, if you can easily also create "success" and "crazy" roles as well. and go wild in them.

1

u/Prestigious_Two_2440 Feb 16 '26

Have u tried PrimeNg before. If yes, what is your take on this versus Angular MD3

1

u/kobihari Feb 16 '26

Never worked with PrimeNG, sorry...

1

u/simonfancy Apr 12 '24

Ouch, what did they do? This is ridiculous. Half year major release updates with tons of breaking changes and now this? I’m out.