navs.html 7.54 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
2
3
4
5
<div class="bs-docs-section">
  <h1 id="nav" class="page-header">Navs</h1>

  <p class="lead">Navs available in Bootstrap have shared markup, starting with the base <code>.nav</code> class, as well as shared states. Swap modifier classes to switch between each style.</p>

Chris Rebert's avatar
Chris Rebert committed
6
  <div class="bs-callout bs-callout-info" id="callout-navs-tabs-plugin">
7
8
9
10
    <h4>Using navs for tab panels requires JavaScript tabs plugin</h4>
    <p>For tabs with tabbable areas, you must use the <a href="../javascript/#tabs">tabs JavaScript plugin</a>. The markup will also require additional <code>role</code> and ARIA attributes – see the plugin's <a href="../javascript/#tabs-usage">example markup</a> for further details.</p>
  </div>

Chris Rebert's avatar
Chris Rebert committed
11
  <div class="bs-callout bs-callout-warning" id="callout-navs-accessibility">
12
13
14
15
    <h4>Make navs used as navigation accessible</h4>
    <p>If you are using navs to provide a navigation bar, be sure to add a <code>role="navigation"</code> to the most logical parent container of the <code>&lt;ul&gt;</code>, or wrap a <code>&lt;nav&gt;</code> element around the whole navigation. Do not add the role to the <code>&lt;ul&gt;</code> itself, as this would prevent it from being announced as an actual list by assistive technologies.</p>
  </div>

Mark Otto's avatar
Mark Otto committed
16
17
18
  <h2 id="nav-tabs">Tabs</h2>
  <p>Note the <code>.nav-tabs</code> class requires the <code>.nav</code> base class.</p>
  <div class="bs-example">
19
    <ul class="nav nav-tabs">
20
21
22
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
23
24
25
    </ul>
  </div>
{% highlight html %}
26
<ul class="nav nav-tabs">
27
28
29
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
30
31
</ul>
{% endhighlight %}
32

Mark Otto's avatar
Mark Otto committed
33
34
35
36

  <h2 id="nav-pills">Pills</h2>
  <p>Take that same HTML, but use <code>.nav-pills</code> instead:</p>
  <div class="bs-example">
37
    <ul class="nav nav-pills">
38
39
40
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
41
42
43
    </ul>
  </div>
{% highlight html %}
44
<ul class="nav nav-pills">
45
46
47
  <li role="presentation" class="active"><a href="#">Home</a></li>
  <li role="presentation"><a href="#">Profile</a></li>
  <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
48
49
50
51
</ul>
{% endhighlight %}
  <p>Pills are also vertically stackable. Just add <code>.nav-stacked</code>.</p>
  <div class="bs-example">
52
    <ul class="nav nav-pills nav-stacked" style="max-width: 300px;">
53
54
55
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
56
57
58
    </ul>
  </div>
{% highlight html %}
59
<ul class="nav nav-pills nav-stacked">
Mark Otto's avatar
Mark Otto committed
60
61
62
63
64
65
66
  ...
</ul>
{% endhighlight %}


  <h2 id="nav-justified">Justified</h2>
  <p>Easily make tabs or pills equal widths of their parent at screens wider than 768px with <code>.nav-justified</code>. On smaller screens, the nav links are stacked.</p>
67
  <p><strong class="text-danger">Justified navbar nav links are currently not supported.</strong></p>
Chris Rebert's avatar
Chris Rebert committed
68
  <div class="bs-callout bs-callout-warning" id="callout-navs-justified-safari">
Mark Otto's avatar
Mark Otto committed
69
    <h4>Safari and responsive justified navs</h4>
70
    <p>As of v8.0, Safari exhibits a bug in which resizing your browser horizontally causes rendering errors in the justified nav that are cleared upon refreshing. This bug is also shown in the <a href="../examples/justified-nav/">justified nav example</a>.</p>
Mark Otto's avatar
Mark Otto committed
71
72
  </div>
  <div class="bs-example">
73
    <ul class="nav nav-tabs nav-justified">
74
75
76
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
77
78
    </ul>
    <br>
79
    <ul class="nav nav-pills nav-justified">
80
81
82
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Profile</a></li>
      <li role="presentation"><a href="#">Messages</a></li>
Mark Otto's avatar
Mark Otto committed
83
84
85
    </ul>
  </div>
{% highlight html %}
86
<ul class="nav nav-tabs nav-justified">
Mark Otto's avatar
Mark Otto committed
87
88
  ...
</ul>
89
<ul class="nav nav-pills nav-justified">
Mark Otto's avatar
Mark Otto committed
90
91
92
93
94
95
96
97
  ...
</ul>
{% endhighlight %}


  <h2 id="nav-disabled-links">Disabled links</h2>
  <p>For any nav component (tabs or pills), add <code>.disabled</code> for <strong>gray links and no hover effects</strong>.</p>

Chris Rebert's avatar
Chris Rebert committed
98
  <div class="bs-callout bs-callout-warning" id="callout-navs-anchor-disabled">
Mark Otto's avatar
Mark Otto committed
99
100
101
102
103
    <h4>Link functionality not impacted</h4>
    <p>This class will only change the <code>&lt;a&gt;</code>'s appearance, not its functionality. Use custom JavaScript to disable links here.</p>
  </div>

  <div class="bs-example">
104
    <ul class="nav nav-pills">
105
106
107
      <li role="presentation"><a href="#">Clickable link</a></li>
      <li role="presentation"><a href="#">Clickable link</a></li>
      <li role="presentation" class="disabled"><a href="#">Disabled link</a></li>
Mark Otto's avatar
Mark Otto committed
108
109
110
    </ul>
  </div>
{% highlight html %}
111
<ul class="nav nav-pills">
Mark Otto's avatar
Mark Otto committed
112
  ...
113
  <li role="presentation" class="disabled"><a href="#">Disabled link</a></li>
Mark Otto's avatar
Mark Otto committed
114
115
116
117
118
119
120
121
122
123
  ...
</ul>
{% endhighlight %}


  <h2 id="nav-dropdowns">Using dropdowns</h2>
  <p>Add dropdown menus with a little extra HTML and the <a href="../javascript/#dropdowns">dropdowns JavaScript plugin</a>.</p>

  <h3>Tabs with dropdowns</h3>
  <div class="bs-example">
124
    <ul class="nav nav-tabs">
125
126
127
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Help</a></li>
      <li role="presentation" class="dropdown">
128
        <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
Mark Otto's avatar
Mark Otto committed
129
130
131
132
133
134
135
136
137
138
139
140
141
          Dropdown <span class="caret"></span>
        </a>
        <ul class="dropdown-menu" role="menu">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li class="divider"></li>
          <li><a href="#">Separated link</a></li>
        </ul>
      </li>
    </ul>
  </div>
{% highlight html %}
142
<ul class="nav nav-tabs">
Mark Otto's avatar
Mark Otto committed
143
  ...
144
  <li role="presentation" class="dropdown">
145
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
Mark Otto's avatar
Mark Otto committed
146
147
      Dropdown <span class="caret"></span>
    </a>
148
    <ul class="dropdown-menu" role="menu">
Mark Otto's avatar
Mark Otto committed
149
150
151
152
153
154
155
156
157
      ...
    </ul>
  </li>
  ...
</ul>
{% endhighlight %}

  <h3>Pills with dropdowns</h3>
  <div class="bs-example">
158
    <ul class="nav nav-pills">
159
160
161
      <li role="presentation" class="active"><a href="#">Home</a></li>
      <li role="presentation"><a href="#">Help</a></li>
      <li role="presentation" class="dropdown">
162
        <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
Mark Otto's avatar
Mark Otto committed
163
164
165
166
167
168
169
170
171
172
173
174
175
          Dropdown <span class="caret"></span>
        </a>
        <ul class="dropdown-menu" role="menu">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li class="divider"></li>
          <li><a href="#">Separated link</a></li>
        </ul>
      </li>
    </ul>
  </div><!-- /example -->
{% highlight html %}
176
<ul class="nav nav-pills">
Mark Otto's avatar
Mark Otto committed
177
  ...
178
  <li role="presentation" class="dropdown">
179
    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
Mark Otto's avatar
Mark Otto committed
180
181
      Dropdown <span class="caret"></span>
    </a>
182
    <ul class="dropdown-menu" role="menu">
Mark Otto's avatar
Mark Otto committed
183
184
185
186
187
188
189
      ...
    </ul>
  </li>
  ...
</ul>
{% endhighlight %}
</div>