Add custom class to Tabs - ngbTabTitleClass
See original GitHub issueSimilar to #1349, I was handed a requirement that would be best solved by conditionally setting a class on the <li>
generated by ngbTab, using the same type options as ngClass:
<ngb-tabset>
<ngb-tab *ngFor="let tab of tabs">
<template ngbTabTitle [ngbTabTitleClass]="tab.classes">tab.title</template>
<template ngbTabContent>tab.content</template>
</ngb-tab>
</ngb-tabset>
I’d expect this could be done by adding the input to ngbTabTitle and updating the ngbTabSet template:
@Directive({selector: 'template[ngbTabTitle]'})
export class NgbTabTitle {
constructor(public templateRef: TemplateRef<any>) {}
@Input() ngbTabTitleClass: string|string[]|Set<string>|{[klass: string]: any};
}
<li class="nav-item" *ngFor="let tab of tabs" [ngClass]="tab.titleTpl?.ngbTabTitleClass">
<a [id]="tab.id" class="nav-link" [class.active]="tab.id === activeId" [class.disabled]="tab.disabled"
href (click)="!!select(tab.id)" role="tab" [attr.aria-controls]="tab.id + '-panel'" [attr.aria-expanded]="tab.id === activeId">
{{tab.title}}<template [ngTemplateOutlet]="tab.titleTpl?.templateRef"></template>
</a>
</li>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:22 (5 by maintainers)
Top Results From Across the Web
A brand new website interface for an even better experience!
Add custom class to Tabs - ngbTabTitleClass.
Read more >AngularJs - Adding Custom class on UI-Bootstrap's Tab
You want to add a custom class to the <ul> instead of the surrounding <div> ? Do you need this only for one...
Read more >Custom CSS Tab for ShortPoint Design Elements
Before we begin · Customizing ShortPoint Design Element · Advanced options. Adding ID attribute; Adding Class attribute. Allow Copying ShortPoint ...
Read more >How to configure Facebook Tabs - Main Street Sites :: Login
Below we will show you how to create a new page for showing your class schedule. The custom menu can be used to...
Read more >Tabs and Categories displaying on the booking ... - Bookeo
The booking mode showing upcoming classes on your booking page automatically displays classes ... Customize tabs names; How to identify the type of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it worked for me by mentioning style globally as given below. Its not working in component classes.
.nav-tabs .nav-link:hover { background-color: #FFFFFF !important; } .nav-tabs .nav-link:hover a { text-decoration: none; }
Is there still no way to add class to ul? I already have styles that works based on the class in ul. I don’t want to rewrite the css again.