With Bootstrap 2.3.2 you could use the nav-header
class as follows to create a grouped list.
<ul class="nav nav-pills nav-stacked">
<li class="nav-header">Group A</li>
<li><a href="/items/1">Item 1</a></li>
<li><a href="/items/2">Item 2</a></li>
<li><a href="/items/3">Item 3</a></li>
<li class="nav-header">Group B</li>
<li><a href="/items/4">Item 4</a></li>
<li><a href="/items/5">Item 5</a></li>
</ul>
Reference
In Bootstrap 3.0.0 the nav-header
class seems to have been removed, though I can't find any mention of it being removed in the docs. I also can't find a replacement.
Is this kind of functionality still present? If so, what's the new way?
Regarding LESS files and Github project, nav-list
and nav-header
has never existed in Bootstrap 3. I guess it has been forgotten.
You can get a similar behavior using this kind of hack:
ul {
width: 300px;
margin: 20px;
}
.nav > li.nav-header > a {
cursor: default;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav nav-pills nav-stacked">
<li class="nav-header"><a>Group A</a></li>
<li><a href="/items/1">Item 1</a></li>
<li><a href="/items/2">Item 2</a></li>
<li><a href="/items/3">Item 3</a></li>
<li class="nav-header"><a>Group B</a></li>
<li><a href="/items/4">Item 4</a></li>
<li><a href="/items/5">Item 5</a></li>
</ul>
Wrap your header in a <a>
, add the class .disabled
and create your own .nav-header
class.
EDIT
According to this issue and this changelog, nav-list
has been replaced by list-group
, but you don't have any real way to get the same behavior for headers.
Even though your nav list isn't a dropdown using the dropdown-header
css class will work.
<ul class="nav nav-pills nav-stacked">
<li class="dropdown-header">Group A</li>
<li><a href="/items/1">Item 1</a></li>
<li><a href="/items/3">Item 3</a></li>
<li class="dropdown-header">Group B</li>
<li><a href="/items/4">Item 4</a></li>
<li><a href="/items/5">Item 5</a></li>
</ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With