jQuery Mobile Navbars
A navbar consists of a group of horizontally arranged links, usually contained in a header or footer.
By default, links in a navbar automatically become buttons (no need for data-role="button").
Use the data-role="navbar" attribute to define a navbar:
Example
Try it »
![]() |
By default, a button's width is the same as its content. Use an unordered list to evenly divide the width of the buttons: 1 button takes 100% width, 2 buttons each take 50%, and 3 buttons each take 33.3%, and so on. However, if you specify more than 5 buttons in a navbar, they will be split into multiple rows (see "More Examples"). |
|---|
Navigation button icons
We can use the data-icon attribute to add icons to navigation buttons:
Example
| Attribute values |
| data-icon="home" |
| data-icon="arrow-r" |
| data-icon="search" |
For a complete reference manual of all jQuery Mobile button icons, visit our jQuery Mobile Icon Reference Manual。
Position icons
Just like the "ui-btn-icon-position" class (detailed in the icon chapter), you can set where the icon is displayed: top, right, bottom, or left.
The icon position is set on the navbar container, using the data-iconpos attribute to specify the position:
| Attribute values | Description | Example |
|---|---|---|
| data-iconpos="top" | Icon top alignment | Try it |
| data-iconpos="right" | Icon right alignment | Try it |
| data-iconpos="bottom" | Icon bottom alignment | Try it |
| data-iconpos="left" | Icon left alignment | Try it |
![]() |
By default, the icon of a navigation button is above the text (data-iconpos="top"). |
|---|
Active button
When a link in a navbar is clicked, it gets the selected (pressed) appearance.
To get this appearance without clicking the link, use class="ui-btn-active":
Example
Try it »
For multiple pages, you may want each button's selected appearance to represent the page the user is currently on. To do this, add "ui-state-persist" and "ui-btn-active" to the link's class:
Example
Try it »
More examples
Navbar in content
How to add a navbar inside data-role="content".
Navbar in the footer
How to add a navbar inside a footer.
Positioning icons in a navbar
How to position icons in a navbar inside a footer.
More than 5 buttons
A demonstration of 10 buttons in a navbar.
