You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs incorrectly stated that the icon position could be set per
link, but this is intended as a global setting for the navbar parent.
This is working as designed and helps with visual consistency. If icon
positioning needs to be be adjusted per link, you will need to manually
apply the right classes through JS and may need to tweak CSS because
top/bottom and left/right positions have different heights.
<p>jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar , typically within a header or footer. </p>
28
-
27
+
<p>jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar, typically within a header or footer. There is also a <ahref="footer-persist-a.html">persistent nav bar</a> variation that works more like a tab bar that stays fixed as you navigate across pages.</p>
29
28
<p>A navbar is coded as an unordered list of links wrapped in a container element that has the <code> data-role="navbar"</code> attribute. To set one of links to the active (selected) state, add <code>class="ui-btn-active"</code> to the anchor. In this example, we have a two-button navbar in the footer with the "One" item set to active:</p>
<p>The navbar items are set to divide the space evenly so in this case, each button is 1/2 the width of the browser window:</p>
43
40
44
-
<divdata-role="footer">
41
+
45
42
<divdata-role="navbar">
46
43
<ul>
47
44
<li><ahref="#" class="ui-btn-active">One</a></li>
48
45
<li><ahref="#">Two</a></li>
49
46
</ul>
50
47
</div><!-- /navbar -->
51
-
</div><!-- /footer -->
48
+
52
49
53
50
<p>Adding a third item will automatically make each button 1/3 the width of the browser window:</p>
54
51
55
-
<divdata-role="footer">
52
+
56
53
<divdata-role="navbar">
57
54
<ul>
58
55
<li><ahref="#" class="ui-btn-active">One</a></li>
59
56
<li><ahref="#">Two</a></li>
60
57
<li><ahref="#">Three</a></li>
61
58
</ul>
62
59
</div><!-- /navbar -->
63
-
</div><!-- /footer -->
60
+
64
61
65
62
<p>Adding a fourth more item will automatically make each button 1/4 the width of the browser window:</p>
66
63
67
-
<divdata-role="footer">
64
+
68
65
<divdata-role="navbar" data-grid="c">
69
66
<ul>
70
67
<li><ahref="#" class="ui-btn-active">One</a></li>
@@ -73,11 +70,11 @@ <h2>Simple navbar</h2>
73
70
<li><ahref="#">Four</a></li>
74
71
</ul>
75
72
</div><!-- /navbar -->
76
-
</div><!-- /footer -->
73
+
77
74
78
75
<p>The navbar maxes out with 5 items, each 1/5 the width of the browser window:</p>
79
76
80
-
<divdata-role="footer">
77
+
81
78
<divdata-role="navbar" data-grid="d">
82
79
<ul>
83
80
<li><ahref="#" class="ui-btn-active">One</a></li>
@@ -87,11 +84,10 @@ <h2>Simple navbar</h2>
87
84
<li><ahref="#">Five</a></li>
88
85
</ul>
89
86
</div><!-- /navbar -->
90
-
</div><!-- /footer -->
87
+
91
88
92
89
<p>If more than 5 items are added, the navbar will simply wrap to multiple lines:</p>
93
90
94
-
<divdata-role="footer">
95
91
<divdata-role="navbar">
96
92
<ul>
97
93
<li><ahref="#" class="ui-btn-active">One</a></li>
@@ -106,17 +102,14 @@ <h2>Simple navbar</h2>
106
102
<li><ahref="#">Ten</a></li>
107
103
</ul>
108
104
</div><!-- /navbar -->
109
-
</div><!-- /footer -->
110
105
111
106
<p>As a fallback, navbars with 1 item will simply render as 100%.</p>
112
107
113
-
<divdata-role="footer">
114
108
<divdata-role="navbar">
115
109
<ul>
116
110
<li><ahref="#" class="ui-btn-active">One</a></li>
117
111
</ul>
118
112
</div><!-- /navbar -->
119
-
</div><!-- /footer -->
120
113
121
114
<h2>Navbars in headers</h2>
122
115
@@ -135,9 +128,33 @@ <h1>I'm a header</h1>
135
128
</div><!-- /navbar -->
136
129
</div><!-- /header -->
137
130
131
+
<h2>Navbars in footers</h2>
132
+
133
+
<p>If you want to add a navbar to the bottom of the page so it acts more like a tab bar, simply wrap the navbar in a container with a <code>data-role="footer"</code></p>
<p>Icons can be added to navbar items by adding the <code> data-icon</code> attribute specifying a <ahref="../buttons/buttons-icons.html">standard mobile icon</a> to each anchor.</p>
157
+
<p>Icons can be added to navbar items by adding the <code> data-icon</code> attribute specifying a <ahref="../buttons/buttons-icons.html">standard mobile icon</a> to each anchor. By default icons are added above the text (<code>data-iconpos="top"</code>). The following examples add icons to a navbar in a footer.</p>
141
158
142
159
<divdata-role="footer">
143
160
<divdata-role="navbar">
@@ -149,14 +166,41 @@ <h2>Icons in navbars</h2>
149
166
</div><!-- /navbar -->
150
167
</div><!-- /footer -->
151
168
152
-
<p>Icons can be stacked above the labels by adding the <code> data-iconpos="top"</code> attribute to each anchor.</p>
169
+
<p>The icon position is set <em>on the navbar container</em> instead of for individual links within for visual consistency. For example, to place the icons below the labels, add the <code> data-iconpos="bottom"</code> attribute to navbar container.</p>
@@ -194,14 +238,44 @@ <h2>Using 3rd party icon sets</h2>
194
238
195
239
<h2>Theming navbars</h2>
196
240
197
-
<p>Navbars can be set to any theme color by <code> data-theme</code> attribute to the links and specifying any theme swatch.</p>
241
+
<p>Navbars inherit the theme swatch from their parent container, just like buttons. If a navbar is placed in header or footer toolbar, it will inherit the default toolbar swatch (A) for bars unless you set this in the markup. </p>
242
+
<p>Here are a few examples of navbars in various container swatches automatically inheriting their parent's swatch letter. Note that in these examples, instead of using a <code>data-theme</code> attribute, we're manually adding the swatch classes to apply the body swatch (<code>ui-body-a</code>) and the class to add the standard body padding (ui-body), but the inheritance works the same way:</p>
198
243
244
+
<divclass="ui-body-a ui-body">
245
+
<h3>Swatch A</h3>
246
+
<divdata-role="navbar">
247
+
<ul>
248
+
<li><ahref="#" data-icon="grid">A</a></li>
249
+
<li><ahref="#" data-icon="star">B</a></li>
250
+
<li><ahref="#" data-icon="gear">C</a></li>
251
+
<li><ahref="#" data-icon="arrow-l">D</a></li>
252
+
<li><ahref="#" data-icon="arrow-r">E</a></li>
253
+
</ul>
254
+
</div><!-- /navbar -->
255
+
</div><!-- /container -->
256
+
257
+
<divclass="ui-body-d ui-body">
258
+
<h3>Swatch B</h3>
259
+
<divdata-role="navbar">
260
+
<ul>
261
+
<li><ahref="#" data-icon="grid">A</a></li>
262
+
<li><ahref="#" data-icon="star">B</a></li>
263
+
<li><ahref="#" data-icon="gear">C</a></li>
264
+
<li><ahref="#" data-icon="arrow-l">D</a></li>
265
+
<li><ahref="#" data-icon="arrow-r">E</a></li>
266
+
</ul>
267
+
</div><!-- /navbar -->
268
+
</div><!-- /container -->
269
+
270
+
<p>To set to the theme color for a navbar item, add the <code>data-theme</code> attribute to the individual links and specify a theme swatch. Note that applying a theme swatch at the navbar container is <em>not</em> supported.</p>
0 commit comments