One data grid for JavaScript, React, Vue & Angular. Sorting, filtering, virtualization, pinning, and CSV export included. Early access $199 $349 → [Get it now]

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. 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 Convert a Map to an Array in JavaScript
How to Convert a Map to an Array in JavaScript

How to Center a Button in CSS
How to Center a Button in CSS

How to Hide Scrollbar with CSS
How to Hide Scrollbar with CSS

How to Use JavaScript setTimeout()
How to Use JavaScript setTimeout()

Answers by CoreUI Core Team