Lists

Home

Basic lists

A list starts as a simple unordered list with a data-role="listview" attribute. jQuery Mobile will apply all the necessary styles to transform the list into a mobile-friendly list view that fills the full width of the browser window. When you tap on the list item, the framework will trigger a click on the first link inside the list item, issue an AJAX request for the URL in the link, create the new page in the DOM, then kick off a page transition.

Basic list example

Nested lists

By nesting child ul of ol inside list items, you can create nested lists. When a list item with a child list is clicked, the framework will generate a new ui-page populated with the title of the parent in the header and the list of child elements. These dynamic nested lists are styled with the "b" theme swatch (blue in the default theme) to indicate that you are in a secondary level of navigation. Lists can be nested multiple level deep and all pages and linking will be automatically handled by the framework.

Nested list example

Numbered lists

Lists can also be created from ordered lists (ol) which is useful when presented items that are in a sequence such as search results or a movie queue. When the enhanced markup is applied to the list view, jQuery Mobile will try to first use CSS to add numbers to the list and, if not supported, will fall back to injecting numbers with JavaScript.

Numbered list example

Split lists

In cases where there is more than one possible action per list item, a split button can be used to offer two independently clickable items -- the list item and a small arrow icon in the far right. To make a split list item, simply add a second link inside the li and the framework will add a vertical divider line, style the link as an icon-only arrow button, and sets the title attribute of the link to the text the link for accessibility.

Split list example

List dividers

List items can be turned into dividers to organize and group the list items. This is done by adding the data-role="list-divider" to any list item. These items are styled in a header class (swatch "c" by defaut") and won't be clickable.

List divider example

Text formatting & counts

The framework includes text formatting conventions for common list patterns like header/descriptions, secondary information, counts through HTML semantic markup.

  • To add a count indicator to the right of the list item, wrap the number in an element with a class of ui-li-count
  • To add text hierarchy, use headings to increase font emphasis and use paragraphs to reduce emphasis.
  • Supplemental information can be added to the right of each list item by wrapping content in an element with a class of ui-li-aside
  • To add thumbnails to the left of a list item, add an image
List divider example

Inset lists

If lists are embedded in a page with other types of content, an inset list packages the list into a block that sits inside the content area with a bit of margin and rounded corners (theme controlled). By adding the data-inset="true" attribute to the list (ul or ol), the list will get the inset appearance.

Inset list example