**Which version of angular are you currently using?
If you want to utilize Angular Material components without affecting the styling of your entire application, here's a method to achieve that:
- Begin by installing Angular Material:
ng add @angular/material
- Import only the necessary modules:
In the module where your component is located, import only the specific Angular Material modules that are required. For instance, if you're utilizing a button and a checkbox, import those modules exclusively:
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
@NgModule({
imports: [
// ... other imports
MatButtonModule,
MatCheckboxModule
],
// ...
})
export class YourModule { }
- Do not incorporate the pre-built Material themes:
Check your angular.json file or global styles document to ensure none of the Material pre-designed themes are included, as they will be applied throughout the whole application. If they are present in a global styles file, consider removing or commenting them out.
For example, Avoid including lines similar to this:
@import '~@angular/material/prebuilt-themes/indigo-pink.css';