-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
docs-bug(*): Missing migration guide to v19 #30055
Comments
This is not only an issue when you want to migrate to the new |
And while this is not related to documentation, may I also suggest to keep the scss in |
Thanks for the feedback. Our previous theme config system was fairly complex and required a deep guide on its mechanics. We're hoping this new system is more straightforward with how it operates, but this means the guide might feel more lightweight than before. Styling custom componentsIn the same pattern of system CSS variables, I'd recommend simply creating a top-level CSS variable for colors you want to use within your application. E.g.
This bypasses the need to create a separate mixin in your component styles that accepts a theme config, and allows you to just put the style directly in your component style. If you want to continue using the mixin concept, you can pass it the palette or color directly. Otherwise, you can always continue creating a theme config that can be passed around, in parallel to using Material 3 theme setup
For a new app, we don't really recommend using Customizing material componentsWhat are you trying to achieve in the line for chips-color? Isn't the default going to be primary? If you are trying to set it with a different color, you can write a selector that targets your mat-chips and redefine the theme as described in https://material.angular.io/guide/theming#context-specific-themes This applies for density as well - you can target the form field and call
However, the |
If this wasn't the case, it'd be helpful to have an issue filed. Our intention is to keep the same behavior/styling preserved for applications in the update process |
Thanks @andrewseguin for your response, it has helped me a lot, but I still have a few issues: Styling custom componentsFor color, replacing And for other styles, for example typography, I was used to do:
and now I should do the following (as described here)
Am I right? It is regrettable that reading theme styles does not follow the same rule as overriding styles, such as:
It would be great to have public APIs to rely on instead of CSS variables that cannot be checked during compilation. Material 3 theme setupI'll file a new issue for Customizing material components
What you suggested do not work for me. I have:
It has no effect, no CSS properties have beean generated.
Is there any way to generate only component related properties? Also, now I need to specify every kind of chips (mat-chip, mat-chip-row and mat-chip-option) and rely on private CSS class or material host tag, both of which can change in the future and are not checked at compile time. Is there any other solution? |
It's not obvious to me how to handle typography for non-component styles. The default styles of |
Thanks, I wasn't aware of an update schematic. My colleague updated the Angular core libraries using |
Because some of my comments on this issue goes beyond the scope "Migrating v18 to v19", I have created a specific request on "how to get theme values without relying on private APIs", see #30083 My main concern now is: How to migrate v18 If the solution is using the new |
For context, here is a before/after comparison on how to change the chip component color: Before in v18:
After in v19:
It's much more complicated now, and if we want to keep the same level of contrast (here tones 10 and 90) we have to inspect the generated code and find the equivalent in the new palette. Proposed solutionIn v18 we had to pick a color from our theme, which wasn't very flexible. An ideal solution would be:
If not doable, then the same behavior as v18 would be good enough:
EDIT : this specfic proposal as now its own issue here: #30241 |
For example in 18 you can define: .secondary-button {
@include mat.button-color($theme, $color-variant: secondary);
} In 19 you have : .secondary-button {
@include mat.button-overrides((
filled-container-color: orange,
filled-label-text-color: red,
....
));
} For some control like icon, it is easy because there is single color, but for other it may be quite complicated. For now, as a workaround I have just done: .secondary-button {
--mat-sys-primary: var(--mat-sys-secondary);
} This works but it is just temporally solution. IMO mat.{component}-overrides should support changing color with single input parameter (for controls that are based on single color) like: .secondary-button {
@include mat.button-overrides((
primary-color: var(--mat-sys-secondary),
));
} |
@martinboue The system level variables should be considered part of the public API. Any changes made to them in the future will be considered breaking and I'd expect us to build schematics to auto-update folks (e.g. renaming or removing variables)
@martinboue You can use the component mixins like
@martinboue You shouldn't need to target a specific selector, just include that in your
@rars The typography hierarchy was a Material 2 typography spec, but that is no longer defined for Material 3. We did our best to mimic a reasonable hierarchy, but since it's not part of the spec I think it makes more sense for clients to set it themselves. You can use this as a reference and modify it if needed: h1 {
font: var(--mat-sys-display-large);
}
h2 {
font: var(--mat-sys-display-medium);
}
h3 {
font: var(--mat-sys-display-small);
}
h4 {
font: var(--mat-sys-headline-large);
}
h5 {
font: var(--mat-sys-headline-medium);
}
h6 {
font: var(--mat-sys-headline-small);
} |
From my understanding, system variables are useful for changing global styles or reusing it for non-material components but are not ideal for customizing material components.
Yes it works for density, but what about color? It's a very common use case to change a material component color but there is no way to do it easily like we used to with Could you please give us an example in v19 of how to change the color of a chip where the result is the equivalent of the |
Expanding on @andrewseguin input. For anyone that is updating to the new mat.theme and used typography-hierachy before here is what I did to get the same effect. theme-typography.scss:
And then i use it in styles.scss:
I do find this slightly better mainly because of future discoverability/maintainability and while I understand the reasoning, I just wished it was mentioned somewhere without searching through issues. |
Recently, I spent several days figuring out how to style a theme in Material 18, including working with use-system-variables, system-variables-prefix, density, and typography, because the documentation is very superficial. Now, I need to do all of this again with Material 19. Additionally, the old API is not fully supported, but the code does not throw any errors, even though my theme no longer works as expected after migration. You really need to improve the documentation and include more examples with links to various templates on GitHub. Perhaps it’s worth considering hiring someone specifically to handle this aspect. |
I've recently investigated how to use Material 18 and thought I had it all figured out. Now, when actually starting the project and using Material 19 I find out the typography mixin is now missing. When/where was that communicated? I inspected the CHANGELOG but can't seem to find the moment in time or a related reference. |
As there are several subjects in this issue, I have a created a specific feature request on "How to change a material component color" which sums up the original problem I had, here: #30241 |
Documentation Feedback
I'm struggling to migrate from Angular Material v18 (with MD3) to v19. I did not find any migration guide and the new guides do not explain the basics as deeply as in the previous version.
Here are the most important use cases that I don't know how to deal with:
Styling custom components
Before
After
I cannot use mat.get-theme-color because I don't have a $theme anymore (previously from mat.define-theme). How can I do that?
Material 3 theme setup
Before
After
It has been automatically replaced to:
What is it for? Why isn't it present if I create a new application with Angular Material? Should it be duplicated? I don't see any documentation mentioning those mixins.
Customising material components
Before
I could do this:
After
How to do the same? Do I need to use the new overrides mixins and set each color tokens? For example, that would be 25 colors for the chip component.
Affected documentation page
https://material.angular.io/guide/theming
The text was updated successfully, but these errors were encountered: