Skip to content
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

bug(angular material): css variables get lost when using multiple themes in angular material #30221

Open
1 task
VILLAN3LL3 opened this issue Dec 20, 2024 · 3 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@VILLAN3LL3
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

using light and dark theme leads to lost styles and css variables

Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-ajqpjxrh?file=src%2Fmain.ts
Steps to reproduce:

  1. press "change theme".
  2. check the stylings (tool tip submit button + click on menu button + styling of mat card header, ...)

Expected Behavior

everything is styled properly in light or dark mode

Actual Behavior

some styles don't seem to be set correctly. See for example the menu overlay or the submit button tooltip. It seems that css variables have been lost, for example --mat-menu-container-shape.

Environment

  • Angular: ^18.2
  • CDK/Material: ^18.2
  • Browser(s): n/a
  • Operating System (e.g. Windows, macOS, Ubuntu): n/a
@VILLAN3LL3 VILLAN3LL3 added the needs triage This issue needs to be triaged by the team label Dec 20, 2024
@VILLAN3LL3 VILLAN3LL3 changed the title bug(COMPONENT): css variables get lost when using multiple themes in angular material bug(angular material): css variables get lost when using multiple themes in angular material Dec 20, 2024
@shhdharmen
Copy link

I don't think it's an issue, it's how you're applying theme to app-root. You need specifically give background to app-root when changing theme. For example, in your index.html file, you can add class mat-app-background with app-root. Plus app-root should be set to display: block.

@VILLAN3LL3
Copy link
Author

Thanks for your quick reply. Your suggestions would fix the card header, but not the overlay issue
https://stackblitz.com/edit/stackblitz-starters-m7wtyfyu?file=src%2Findex.html
Image
Image

@shhdharmen
Copy link

shhdharmen commented Dec 20, 2024

It's because overlays are added in body, not in app-root. For example if you add @include mat.all-component-colors($light-theme); after @include mat.all-component-typographies($base-theme);, you will see light-themed tooltip always.

I would suggest to move theming from app-root to body or html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

2 participants