Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change the styles of mat card which is used in Angular library component

I have used mat-card in angular library component like the below

<mat-card class="la-card">
  <mat-card-header class="la-card__header">
    <mat-card-subtitle>Field</mat-card-subtitle>
    <mat-card-title>Case title</mat-card-title>
  </mat-card-header>
  <mat-card-content class="la-card__content">
    <p>
      The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan.
      A small.
    </p>
  </mat-card-content>
  <mat-card-actions class='la-card__actions'>
    <button mat-button>Created</button>
    <button mat-button>Details</button>
  </mat-card-actions>

and i gave the style like the below

.la-card__header {
    margin: 0;
    flex-shrink: 0;

    .mat-card-header-text {
      margin: 0;
    }
  }

The margin '0' is not applying to header text class .mat-card-header-text. How can i remove the margin to that classs. That class i can see when i inspect the mat-card component.

like image 861
Roster Avatar asked Sep 06 '25 21:09

Roster


1 Answers

Use the following css selector to reach deep angular classes ::ng-deep.

CSS rule that resets margin in this case would be:

::ng-deep .mat-card-header-text {
  margin: 0;
}

And as for a full code snippet it would be:

.la-card__header {
  margin: 0;
  flex-shrink: 0;

  ::ng-deep .mat-card-header-text {
    margin: 0;
  }
}

Hope This helped.

like image 86
Mohamed Karkotly Avatar answered Sep 09 '25 18:09

Mohamed Karkotly