Header configuration

Header bar structure

The header is an bar at the top of the page that usually contains the page title text and optional buttons positioned in the the left or right of the title for navigation or actions. The title text is normally an H1 heading element but it's possible to use any heading level (H1-H6) to allow for semantic flexibility. For example, a page containing multiple mobile 'pages' may use a H1 element on the home 'page' and a H2 element on the secondary pages. All heading levels are styled identically by default to maintain visual consistency.

<div data-role="header"> 
	<h1>Page Title</h1> 
</div> 

Header buttons

In the standard header configuration, there are slots for up to two buttons on either side of the text heading. Each button is an anchor element that points to any URI. The button's width fits the length of the text and icons it contains. The header plugin looks for immediate children of the header container and will automatically set the first link found in the left button slot and the second link in the right button slot.

In this example, the Home button will appear in the left slot and Edit will appear in the right slot. If you want to add custom HTML markup (or embed a widget like Nav Bar) into the header bar, simply wrap the markup in a container div and the plugin won't apply the automatic button slot logic.

<div data-role="page"> 
	<div data-role="header"> 
		<a href="index.php">Home</a> 
		<h1>Page Title</h1> 
		<a href="edit.php">Edit</a> 
	</div> 
</div> 

The button position can also be controlled by adding classes to the button anchors instead of relying on source order. This is especially useful if there isn't a left button and you only want a button in the right slot. To specify the button position, add the class of ui-btn-left or ui-btn-right to the anchor.

<a href="tools.php" class="ui-btn-right">Tools</a> 

If there isn't a user-defined button in the left slot, the framework will auto-generate a "back" button in that slot to automate the process of including this common navigation element on every page. To prevent the back button from being added to a header in these situations, add this attribute: data-nobackbtn="true".

Bar & button theme styling

The header will be styled by default with the theme's "a" color swatch (black in the default theme) because these bars are typically primary in the visual hierarchy of a page. To set the header to a different color in your theme, add the data-theme attribute and specify the letter of the theme swatch (a, b, c, etc.). For example, this will set the bar to swatch "b" (blue in the default theme):

<div data-role="header" data-theme="b"> 
<h1>Page Title</h1> 
</div> 

Any link added inside the header block will be automatically styled as a button that matches the color of the bar's theme swatch. To make a button stand out as a primary call to action, the data-theme attribute can be used to specify a contrasting button color from a different theme swatch. For example, if we set the header to theme "c" (light gray), both buttons would be styled as the "c" button by default. If we wanted the Save button to visually pop, we can override the color by setting the data-theme attribute to "b" (blue in our default theme) on the Save button's anchor.

<a href="add-user.php" data-theme="b">Save</a> 
Themed header examples