##

Demos

Menu Search

# Navbar

jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar.

## Navbar basics

A navbar is coded as an unordered list of links wrapped in a container element that has the `data-role="navbar"` attribute. When a link in the navbar is clicked it gets the active (selected) state. The `ui-btn-active` class is first removed from all anchors in the navbar before it is added to the activated link. If this is a link to another page, the class will be removed again after the transition has completed.

To set an item to the active state, add `class="ui-btn-active"` to an anchor in the markup. Additionally add a class of `ui-state-persist` to make the framework restore the active state each time the page is shown while it exists in the DOM.

Navbars with 1 item will render as 100% wide.

- One

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:

- One
- Two

Adding a third item will automatically make each button 1/3 the width of the browser window:

- One
- Two
- Three

Adding a fourth more item will automatically make each button 1/4 the width of the browser window:

- One
- Two
- Three
- Four

The navbar maxes out with 5 items, each 1/5 the width of the browser window:

- One
- Two
- Three
- Four
- Five

## Multi-row

If more than 5 items are added, the navbar will simply wrap to multiple lines of two across:

- One
- Two
- Three
- Four
- Five
- Six
- Seven
- Eight
- Nine
- Ten

## Navbars in headers

If you want to add a navbar to the top of the page, you can still have a page title and buttons. Just add the navbar container inside the header block, right after the title and buttons in the source order.

# I'm a header

Options

- One
- Two
- Three

## Navbars in footers

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 `data-role="footer"`

#### I'm the footer

- One
- Two
- Three

## Persistent

The persistent navbar variation is designed to work more like a tab bar that stays fixed as you navigate across pages. To set an item to the active state upon initialization of the navbar, add `class="ui-btn-active"` to the corresponding anchor in your markup. Additionally add a class of `ui-state-persist` to make the framework restore the active state each time the page is shown while it exists in the DOM.

## Icons

Icons can be added to navbar items by adding the `data-icon` attribute specifying a standard mobile icon to each anchor. By default, icons are added above the text (`data-iconpos="top"`). The following examples add icons to a navbar in a footer.

- Summary
- Favs
- Setup

## Icon position

The icon position is set on the navbar container instead of for individual links within for visual consistency. For example, to place the icons below the labels, add the `data-iconpos="bottom"` attribute to the navbar container.

This will result in a bottom icon alignment:

- Summary
- Favs
- Setup

The icon position can be set to `data-iconpos="left"`:

- Summary
- Favs
- Setup

Or the icon position can be set to `data-iconpos="right"`:

- Summary
- Favs
- Setup

## 3rd party icon sets

You can add any of the popular icon libraries like Glyphish to achieve the iOS style tab that has large icons stacked on top of text labels. All that is required is a bit of custom styles to link to the icons and position them in the navbar. Here is an example using Glyphish icons and custom styles (view page source for styles) in our navbar:

Icons by Joseph Wain / glyphish.com. Licensed under the Creative Commons Attribution 3.0 United States License.

## Themes

Navbars inherit the theme swatch from their parent container, just like buttons. If a navbar is placed in the header or footer toolbar, it will inherit the default toolbar swatch "a" for bars unless you set this in the markup.

Here are a few examples of navbars in various container swatches that automatically inherit their parent's swatch letter. Note that in these examples, instead of using a `data-theme` attribute, we're manually adding the swatch classes to apply the body swatch (`ui-body-a`) and the class to add the standard body padding (ui-body), but the inheritance works the same way:

### Swatch "a"

- A
- B
- C
- D
- E

### Swatch "b"

- A
- B
- C
- D
- E

To set the theme color for a navbar item, add the `data-theme` attribute to the individual links and specify a theme swatch. Note that applying a theme swatch to the navbar container is not supported.

- A
- B

- Home

- ### Getting started

  - Introduction
  - Responsive Web Design

- ### Pages

  - Pages
  - Single page
  - Multi-page template
  - Dialog page

- ### Navigation

  - Navigation
  - Linking pages
  - PHP redirect demo
  - Transitions
  - Loader

- ### Events

  - Swipe list items
  - Swipe page navigation

- ### Theme

  - Default theme
  - Classic theme
- Buttons

- ### Icons

  - Icons
  - Icons load script

- ### Toolbars

  - Toolbar
  - Dynamic toolbars
  - External toolbars
  - Fixed toolbars
  - Fullscreen toolbars
  - Fixed external toolbars
  - Persistent toolbars
  - AJAX optimized toolbars
  - Form in toolbar
  - Navbar widget
- Tabs

- ### Panels

  - Panel
  - External panels
  - Fixed panels
  - Panels responsive
  - Custom panel style
  - Panel open on swipe
  - Panel external and internal

- ### Popups

  - Popup
  - Popup alignment
  - Popup arrow size
  - Dynamic popups
  - Popups with iframes
  - Popup image scaling
  - Popup outside multi-page

- ### Collapsibles

  - Collapsible
  - Dynamic collapsibles
  - Collapsible set

- ### Listviews

  - Listview
  - Listview autocomplete
  - Listview autocomplete remote data
  - Listview autodividers linkbar
  - Listview autodividers selector
  - Listview collapsible list items (flat)
  - Listview collapsible list items (indented)
  - Listview responsive grid

- ### Tables

  - Table Column Toggle
  - Table Column Toggle demo
  - Table Column Toggle heading groups
  - Table Column Toggle options
  - Table Reflow
  - Table Reflow heading groups
  - Table Reflow stripes and strokes
  - Table Reflow custom styles
- Filterable

- ### Forms

  - Forms
  - Forms gallery
  - Forms disabled
  - Field containers
  - Hide labels
  - Textinput
  - Input button
  - Checkboxes
  - Radio buttons
  - Selectmenu
  - Custom select menu
  - Custom select menu with filter
  - Slider
  - Slider flip toggle switch
  - Slider tooltip
  - Rangeslider
  - Flipswitch

- ### Controlgroups

  - Controlgroup
  - Dynamic controlgroups

- ### Grids

  - Grids
  - Buttons in grids
  - Custom responsive grids

- ### 3rd party API

  - Backbone RequireJS
  - Google Maps geolocation
  - Google Maps list toggle

- Home

- ### Getting started

  - Introduction
  - Responsive Web Design

- ### Pages

  - Pages
  - Single page
  - Multi-page template
  - Dialog page

- ### Navigation

  - Navigation
  - Linking pages
  - PHP redirect demo
  - Transitions
  - Loader

- ### Events

  - Swipe list items
  - Swipe page navigation

- ### Theme

  - Default theme
  - Classic theme
- Buttons

- ### Icons

  - Icons
  - Icons load script

- ### Toolbars

  - Toolbar
  - Dynamic toolbars
  - External toolbars
  - Fixed toolbars
  - Fullscreen toolbars
  - Fixed external toolbars
  - Persistent toolbars
  - AJAX optimized toolbars
  - Form in toolbar
  - Navbar widget
- Tabs

- ### Panels

  - Panel
  - External panels
  - Fixed panels
  - Panels responsive
  - Custom panel style
  - Panel open on swipe
  - Panel external and internal

- ### Popups

  - Popup
  - Popup alignment
  - Popup arrow size
  - Dynamic popups
  - Popups with iframes
  - Popup image scaling
  - Popup outside multi-page

- ### Collapsibles

  - Collapsible
  - Dynamic collapsibles
  - Collapsible set

- ### Listviews

  - Listview
  - Listview autocomplete
  - Listview autocomplete remote data
  - Listview autodividers linkbar
  - Listview autodividers selector
  - Listview collapsible list items (flat)
  - Listview collapsible list items (indented)
  - Listview responsive grid

- ### Tables

  - Table Column Toggle
  - Table Column Toggle demo
  - Table Column Toggle heading groups
  - Table Column Toggle options
  - Table Reflow
  - Table Reflow heading groups
  - Table Reflow stripes and strokes
  - Table Reflow custom styles
- Filterable

- ### Forms

  - Forms
  - Forms gallery
  - Forms disabled
  - Field containers
  - Hide labels
  - Textinput
  - Input button
  - Checkboxes
  - Radio buttons
  - Selectmenu
  - Custom select menu
  - Custom select menu with filter
  - Slider
  - Slider flip toggle switch
  - Slider tooltip
  - Rangeslider
  - Flipswitch

- ### Controlgroups

  - Controlgroup
  - Dynamic controlgroups

- ### Grids

  - Grids
  - Buttons in grids
  - Custom responsive grids

- ### 3rd party API

  - Backbone RequireJS
  - Google Maps geolocation
  - Google Maps list toggle