question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add custom class to Tabs - ngbTabTitleClass

See original GitHub issue

Similar 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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
sunillakhlancommented, Oct 12, 2017

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; }

3reactions
sharathdanielcommented, Apr 4, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found