1

I wanted to change mat label color for a mat-tab. css that I've added is:

.mat-tab-label {
  min-width: 25px !important;
  padding: 5px;
  background-color: transparent;
  color: white;
  opacity: 1 !important;
  font-weight: 700;
}

It is changing color for tab. But, it is changing color for all mat-tabs in whole application. How can I change for a particular tab alone.

5
  • 1
    if you are setting the style for the tab in the global style.css or scss it will be change for all. You need to add a file for isolate into the component where you want to use that style. Commented Jul 9, 2020 at 8:46
  • @anthonywillismuñoz you are right. Commented Jul 9, 2020 at 8:51
  • I added css to individual component. But, it is reflecting on all Commented Jul 9, 2020 at 8:54
  • Try adding to style.css it will works. @MaruthiEranki Commented Jul 9, 2020 at 8:56
  • I moved to style.css and added component as prefix to .mat-tab-label. That fixed the issue. Commented Jul 9, 2020 at 10:05

2 Answers 2

1

You can use the component tag label,

 app-component-name .mat-tab-label {
    min-width: 25px !important;
    padding: 5px;
    background-color: transparent;
    color: white;
    opacity: 1 !important;
    font-weight: 700;
}

Or add a class to the tab

Sign up to request clarification or add additional context in comments.

Comments

1

You have to override class style in style.css or style.scss

.mat-tab-label {
  min-width: 25px !important;
  padding: 10px;
  background-color: transparent;
  color: white;
  opacity: 1 !important;
  font-weight: 700;
}

Stackblitz : https://stackblitz.com/edit/angular-mat-tab-active-89vnui

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.