Angular Material customize tab

后端 未结 5 1610
天涯浪人
天涯浪人 2020-12-08 07:04

I\'m using angular 4 and I\'m using Angular Material.


    

        
5条回答
  •  盖世英雄少女心
    2020-12-08 07:42

    In your component, set ViewEncapsulation to None and add the styles in your component.css file.

    Changes in Typescript code:

    import {Component, ViewEncapsulation} from '@angular/core';
    
    @Component({
      ....
      encapsulation: ViewEncapsulation.None
    })
    

    Component CSS:

    /* Styles for tab labels */
    .mat-tab-label {
        min-width: 25px !important;
        padding: 5px;
        background-color: transparent;
        color: red;
        font-weight: 700;
    }
    
    /* Styles for the active tab label */
    .mat-tab-label.mat-tab-label-active {
        min-width: 25px !important;
        padding: 5px;
        background-color: transparent;
        color: red;
        font-weight: 700;
    }
    
    /* Styles for the ink bar */
    .mat-ink-bar {
        background-color: green;
    }
    

    Demo

提交回复
热议问题