79317871

Date: 2024-12-30 14:40:40
Score: 1
Natty:
Report link

Easy way to create accent and other colored buttons in Angular Material v19 is simply to create another theme with your specific colors in a specific CSS selector. E.g.

.accent {
    @include mat.theme(
        (
          color: mat.$magenta-palette,
        )
      );
    }
    
 .warn {
      @include mat.theme(
        (
          color: mat.$red-palette,
        )
      );
    }

And then just simply apply the class to your button when you want.

<button class="accent" mat-flat-button>Accent button</button>

<button class="warn" mat-flat-button>Warn button</button>

I discussed all of this in a recent video, if you'd like more details.

https://youtu.be/5NSH8VvJH5o

Reasons:
  • Blacklisted phrase (1): youtu.be
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Zoaib Ahmed Khan