Migrating Angular Project from Angular 11 to Angular 18: Issues with CSS and Angular Material (mat vs mat-mdc)

I recently migrated my project from Angular 11 to Angular 18, updating all related packages, including Angular Material. After completing the migration, I encountered some issues that I need help resolving.

Context:

My project was initially built with Angular 11.
I upgraded to Angular 18, ensuring all dependencies, including Angular Material, were updated to the latest versions.
After the migration, I noticed several changes in the CSS styling and class names.
Issues:

CSS Styling: The overall appearance of my project has changed. Many of the styles that were previously applied are now either missing or altered.

Class Names: Angular Material has moved from using the mat- prefix to mdc- for certain components. For example, buttons that used to have mat-button classes are now using mdc-button, which has different styling and behavior.

My Questions:

Is there a way to retain the old mat- classes and styles from Angular 11 in Angular 18? I prefer not to adopt the mdc- prefix if possible.
If it’s not possible to retain the old classes, what would be the best approach to ensure that the UI remains consistent with its previous design?
Are there any specific steps or configurations I need to adjust to maintain the look and feel of my project post-migration?
Additional Details:

I’ve reviewed the official Angular Material documentation and migration guides, but I’m still unclear on how to maintain the old styles without significant rewrites.
I’ve attempted to override some of the new mdc- styles with custom CSS, but the results are inconsistent.
Environment:

Angular: 18
Angular Material: Latest version compatible with Angular 18

Any guidance, examples, or resources that could help resolve these issues would be greatly appreciated. Thank you in advance!

  • What I Tried:
  • Reviewing Documentation: I went through the official Angular Material documentation and the migration guides provided, looking for any options to retain the old mat- class names or styles. Unfortunately, I didn’t find any straightforward solutions.

  • Custom CSS Overrides: I attempted to manually override the new mdc- styles by adding custom CSS to mimic the old mat- appearance. However, the results were inconsistent, and maintaining these overrides across the entire project seems impractical and error-prone.

  • Exploring Compatibility Options: I searched for any backward compatibility features or flags in Angular or Angular Material that might allow me to continue using the mat- classes, but I couldn’t find anything that worked.

  • What I Was Expecting:
  • I was hoping to find a way to either:

  • Retain the Old Styles and Classes: Continue using the mat- prefix classes without having to refactor the entire codebase to adopt the new mdc- classes.
    Simple Migration Path: A seamless migration path where the new classes (mdc-) would not drastically change the UI’s look and feel or require significant effort to maintain the previous design consistency.

New contributor

uday is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật