there have been some changes to class names, particularly with the re-implementation of several components based on the Material Design Components (MDC). In this video you will learn how override style of angular material button.
Step 1: Install Angular Material
-------------------------------
To install Angular Material in your Angular project, use Angular CLI's ng add command. Open your terminal or command prompt and run the following command:
ng add @angular/material
This command will guide you through a series of prompts where you can choose a theme, set up global Angular Material typography and animations, and configure other options.
Step 2: Import `MatButtonModule` into Your Component
-----------------------------------------------------
After Angular Material is installed, import the specific Angular Material modules you want to use into your Angular components. For example, to use Angular Material's button component, you would import `MatButtonModule` into your component file. Here's how you would do it:
import { MatButtonModule } from '@angular/material/button';
You also need to add `MatButtonModule` to the `imports` array of your NgModule to make it available in your application.
Step 3: Override Button Designs Using CSS Provided Earlier
----------------------------------------------------------
Once you've imported Angular Material into your component and you want to customize the design of the buttons, you can apply the CSS provided earlier. You can either add this CSS directly to your component's CSS file or to your global styles file, depending on the scope of your customization.
For example, if you want to apply the CSS provided earlier to override the default button styles for primary and accent buttons, you can add it to your component's CSS file like this:
.mat-mdc-raised-button.mat-primary {
background-color: #33b249 !important;
}
.mat-mdc-raised-button.mat-accent {
background-color: red !important;
}
Make sure the CSS file where you place these styles is being loaded into your Angular application. If you're adding it to a component-specific CSS file, it should be automatically included when the component is used.
In case if its not working,
try adding styles in style.scss file.
---------------------------------------------------------------------
if you want to use in component, try use (::ng-deep) if its not working like below
::ng-deep .mat-mdc-raised-button{
background-color: #33b249 !important;
}
Watch video angular material button custom style | Angular Material 17 | MDC [NEW] online without registration, duration hours minute second in high quality. This video was added by user Quick Code Academy 12 February 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,219 once and liked it 21 people.