Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to nav-header class?

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?

like image 448
Timothy Shields Avatar asked Aug 20 '13 07:08

Timothy Shields


2 Answers

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.

like image 149
zessx Avatar answered Nov 01 '22 07:11

zessx


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>
like image 17
Skanaar Avatar answered Nov 01 '22 07:11

Skanaar