How to theme Angular Material components

Creating branded Angular applications requires customizing Material Design components to match your company’s color palette and design system. With over 12 years of Angular experience since 2014 and as the creator of CoreUI, I’ve implemented custom themes for numerous enterprise applications. Angular Material provides a comprehensive theming system based on SCSS that allows you to define primary, accent, and warn color palettes. The approach involves creating a custom theme file and importing it into your application’s main stylesheet.

Create a custom theme file and define color palettes using Angular Material’s theming API.

Create src/custom-theme.scss:

@use '@angular/material' as mat;

@include mat.core();

$my-primary: mat.define-palette(mat.$indigo-palette);
$my-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);
$my-warn: mat.define-palette(mat.$red-palette);

$my-theme: mat.define-light-theme((
  color: (
    primary: $my-primary,
    accent: $my-accent,
    warn: $my-warn,
  )
));

@include mat.all-component-themes($my-theme);

Import in src/styles.scss:

@import './custom-theme.scss';

Best Practice Note

The define-palette function accepts Material Design color palettes and optional hue values for default, lighter, and darker shades. For dark themes, use define-dark-theme instead of define-light-theme. You can create multiple themes and switch between them dynamically by applying CSS classes. To reduce bundle size, import only the component themes you use instead of all-component-themes. This is how we approach theming in CoreUI for Angular—providing pre-built themes while allowing full customization through SCSS variables.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to sleep in Javascript
How to sleep in Javascript

How to set focus on an input field after rendering in React
How to set focus on an input field after rendering in React

What is Double Question Mark in JavaScript?
What is Double Question Mark in JavaScript?

How to Detect a Click Outside of a React Component
How to Detect a Click Outside of a React Component

Answers by CoreUI Core Team