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.

Accordion / Tabset: adding close button in a tab header

See original GitHub issue

It is quite common to have a little close button on each tab of a tabset to close a given tab. Unfortunately we can’t easily add such a button today since content of the ngTabTitle tab is added inside header’s link (<a> element). This setup limits what users can put in a tab header.

Potential solutions:

  • have users provide the whole link as part of the ngTabTitle template - the downside here is that users would have to manage the active and disabled states as well as a selection logic;
  • add a new directive (ngTabHeader) - if provided its content would be added after a link. The downside here is that there might be someone coming and saying that I want to insert sth before a link…

Not sure what is the best course of action here, to be discussed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
aegyed91commented, Jul 23, 2016

This is not valid html, but works fine.

<a class="nav-link active" href="#">
  Active
  <button class="close" type="button">×</button>
</a>

Another solution would be (if nesting templates is possible in ng2):

<ngb-tabset>
  <ngb-tab>
    <template ngbTabHeader>
      <!-- prepend something -->
      <template ngbTabTitle><b>Fancy</b> title</template>
      <!-- append something -->  
    </template>
    <template ngbTabContent>content</template>
  </ngb-tab>
</ngb-tabset>
1reaction
maxokorokovcommented, Feb 21, 2020

Since version 5.2.0 there is a new NgbNav set of directives that fix this issue. NgbNav is meant to replace the NgbTabset component (completely deprecated in version 6.0.0) as a more flexible alternative.

I suggest you migrate to it → https://ng-bootstrap.github.io/#/components/nav/overview

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Accordion / Tabset: adding close button in a tab header -
Accordion / Tabset: adding close button in a tab header. ... It is quite common to have a little close button on each...
Read more >
How to expand/collapse accordion tab when clicking a button?
All tabs are disabled and they are opened/closed programmatically only by clicking on the "Click me" buttons in their headers.
Read more >
Responsive Accordion Tabs | Foundation for Sites 6 Docs
Basics. Either the Accordion Markup or the Tabs Markup can be used to responsively switch between the two components at different breakpoints.
Read more >
Elementor Tab, Toggle or Accordion Remote Control
In this article we will learn how to open a specific toggle, tab and accordion by a button or link click on the...
Read more >
Collapse - Bootstrap
You can use a link with the href attribute, or a button with the data-target attribute. In both cases, the data-toggle="collapse" is required....
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