Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't assign custom class for mat-tab #15997

Open
cziberpv opened this issue May 10, 2019 · 7 comments
Open

Can't assign custom class for mat-tab #15997

cziberpv opened this issue May 10, 2019 · 7 comments
Labels
area: material/tabs P4 A relatively minor issue that is not relevant to core functions

Comments

@cziberpv
Copy link

What is the expected behavior?

[ngClass] used on mat-tab should add class on "mat-tab-label" div

What is the current behavior?

There is no way to add custom class to "mat-tab-label" div

What are the steps to reproduce?

https://stackblitz.com/edit/angular-material2-issue-xq3ql9

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

7.3.7

Is there anything else we should know?

@andrewseguin andrewseguin added the P4 A relatively minor issue that is not relevant to core functions label May 10, 2019
@andrewseguin
Copy link
Contributor

You can provide your own custom content for the tab label but I agree there is no great way to style the entire label (not just text).

https://stackblitz.com/edit/angular-material2-issue-epfe1y?file=app/app.component.ts

@niekvb
Copy link

niekvb commented Aug 23, 2019

Duplicate of #9290

@asphub
Copy link

asphub commented Jan 26, 2021

We can tweak with <ng-template> to add a class for styling the mat-tab-panel

HTML


<mat-tab>
    <ng-template mat-tab-label>
        <span class="deleteTab">Delete Tab</span>
    </ng-template>
...
</mat-tab>

CSS


.deleteTab {
color: red;
}

lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 5, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 5, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 5, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 5, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 5, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 5, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 6, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Oct 7, 2021
lekhmanrus added a commit to lekhmanrus/components that referenced this issue Nov 20, 2021
@liesahead
Copy link

liesahead commented Jan 28, 2022

So, the labelClass input does not work?

Update: works in 13.2.0, great!

@spedroq
Copy link

spedroq commented Feb 11, 2022

Yeah having a way to define classes for the automatically generated components would be very useful. Currently there is no way to differentiate between the different mat-tab-body-content for example.
In other projects I have seen the approach of allowing a bodyClass attribute to be passed for example.

forsti0506 pushed a commit to forsti0506/components that referenced this issue Apr 3, 2022
@exo-pla-net
Copy link

labelClass and bodyClass are still broken.

They don't conform to the docs, nor do they seem to do anything.

@msmallest
Copy link

@exo-pla-net

It seems that the corresponding style definition for the labelClass and bodyClass need to be done in the respective material theme file or app's root style file

Here is a working example I made from the v14 docs, but it works for v17 too
https://stackblitz.com/edit/y3qw5m?file=src%2Fapp%2Ftab-group-align-example.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/tabs P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

8 participants