Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Coding

This article needs a technical review. How you can help.

Download resources

Here you can find examples of how to create tabs on Firefox OS, as well as downloads for the CSS and image resources used by the built-in apps on Firefox OS. You can copy these resources into your app and make use of them to build apps that match these apps' appearances.

Implementing tabs

To implement a tab bar using the style shown here, place the CSS and media files into your app and then import the CSS using the @import at-rule:

@import url(resources/tabs.css);

Make sure the media files are in the location expected by the CSS (either by placing them in a corresponding location or by revising the CSS).

Example

HTML to create the tab bar

The HTML below creates a tab bar with the tabs at the bottom. To move the tab bar to the top of the screen, simply remove the class "bottom" from the <ul> element (ARIA role "tablist") that represents the tab bar. The data-items attribute should indicate how many tabs are in the tab bar.

<section role="region">
  <ul role="tablist" data-items="4" class="bottom">
    <li id="panel1" role="tab">
      <a href="#panel1" class="icon">comms</a>
      <div role="tabpanel"></div>
    </li>
    <li id="panel2" role="tab">
      <a href="#panel2" class="icon">contacts</a>
      <div role="tabpanel"></div>
    </li>
    <li id="panel3" role="tab" aria-disabled="true">
      <a class="icon">dialer</a>
      <div role="tabpanel"></div>
    </li>
    <li id="panel4" role="tab">
      <a href="#panel4">Tab name</a>
      <div role="tabpanel"></div>
    </li>
  </ul>
</section>

Each tab is drawn using an <li> element with the ARIA role "tab" that contains a link.

CSS

The CSS here defines the icons for the tabs.

#panel1 a:after {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAB4CAYAAADogzKiAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxL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Y6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBRTZDMjREMDBDMEMxMUUyOTk1NkE4QTgxRjhCM0I3QSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlXYxucAAAEmSURBVHja7JZNDsFQFEZLjOxGB8Qmugnr0AHrsAcpe/AzqA1gYNIJhiYkdV/y6M3LaySlSSPnJVdaX/XQ9sjXyvM8qHO1g5oXAAAACkBfJncmVcdNPPlE5akn72vA2QO/qO1P+dWTnzXgJHN3DjiWbL/WQW3vnexuz/kGPGTmzgELtb+WydR+Zt97raXzBef2nEGLf1M8wAM8wAM8wAMAAAAAAACgMYCOeRmtbqbDbJxsJxOqXjR28qlMPBt2zedNL+o5+UCyLb2otBfJ5Sl6kVzDyjfR3AM8+N4D2+UreWA9wgM8wAM8+NoDHlMAAAAAAACgGb0oiiJvL0qSJLS5txdJHtvc24sk/5deJD/l573InpNehAd4gAd4gAd4AADA3wCeAgwA2E15Rlze638AAAAASUVORK5CYII=);
}

JavaScript code

We will soon add code here to demonstrate switching views when tabs are clicked.

// none yet

Working demo

You can try out the tabs in this live demonstration.


Firefox OS live demos generally require a Gecko-based browser, and work best in recent builds of Firefox.

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, Sheppy
 Last updated by: chrisdavidmills,