Tabs

Use tabs to organize your article content in a way that makes it easy for your visitors to find what they're looking for.

Standard tabs

Creating tabs within your article content doesn’t involve copying and pasting any HTML as the Tabs extension lets you transform standard ordered (<ol>) and unordered (<ul>) lists created in the article editor into interactive tabs. This makes it easy for visitors to find what they’re looking and allows content creators to focus on producing helpful content.

If you do ever need to migrate your content you can do so without having to worry about unnecessary markup or inline styles.

The default tabs template
View code
<ul class="js-tabs">
  <li data-title="Android">
    <p>Android is a mobile operating system based on a modified version of the Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance and commercially sponsored by Google. It was unveiled in 2007, with the first commercial Android device launched in September 2008.</p>
  </li>
  <li data-title="iOS">
    <p>iOS is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that presently powers many of the company's mobile devices, including the iPhone, and iPod Touch; it also powered the iPad prior to the introduction of iPadOS in 2019. It is the second most popular mobile operating system globally after Android. It is the basis for other operating systems made by Apple Inc, like iPadOS, tvOS, and watchOS.</p>
  </li>
  <li data-title="Windows">
    <p>Windows 10 Mobile is a discontinued mobile operating system developed by Microsoft. First released in 2015, it is a successor to Windows Phone 8.1, but was marketed by Microsoft as being an edition of its PC operating system Windows 10. Windows 10 Mobile aimed to provide greater consistency with its counterpart for PCs, including more extensive synchronization of content, the ability to to connect devices to an external display and use a desktop interface with mouse and keyboard input support.</p>
  </li>
</ul>

The default template is simple, elegant and responsive and will automatically inherit the overall style of your theme. You can add any type of content you like to each tab, including HTML, images, videos and other article formatting styles.

Customized tabs

Customized tabs templates can introduce icons, transition effects and even entirely new layouts like vertical tab links.

Large, justified tabs with icons

Creating tabs

Tabs can be used anywhere in the help center, but often they are used within article content. Our extension allows you to create tabs in several different ways, none of which require you to copy-and-paste any HTML.

The Tabs extension is bundled into all of our themes by default, so you can start using it straight away. The source code can be found within the extensions.(min.)js file in the theme’s Assets folder.

When creating or updating an article using the Zendesk article editor:

  1. Create a numbered (Add numbered list button) or bulleted list (Add bulleted list button) using the editor toolbar and add the content that you’d like to see in each tab within the list items.

  2. Click the Source Code (Source code icon) button in the editor toolbar to view the source code of the page.

  3. Add a class name of .js-tabs to the list element to convert it into a set of interactive tabs.

  4. Add a data-title attribute to each list item containing the title you’d like to use for the tab. Alternatively, you can apply a class name of .tab-heading to an element within the list item and that element’s text content will be used as the tab title.

     <ul class="js-tabs">
       <li data-title="The first tab title">...</li>
       <li data-title="The second tab title">...</li>
       <li>
         <h3 class="tab-heading">The third tab title</h3>
         ...
       </li>
     </ul>
    

    If data attributes are used you will need to ensure that the allow unsafe HTML setting is enabled within Zendesk Guide.

The Tabs extension allows you to convert a standard ordered (<ol>) or unordered (<ul>) list into an interactive set of tabs using JavaScript:

<ul class="js-tabs">
  <li data-title="The first tab">...</li>
  <li data-title="The second tab">...</li>
  <li data-title="The third tab">...</li>
</ul>

<script type="text/javascript">
  ready(function() {
    each('.js-tabs', function(el) {
      new Tabs(el, {
        // Options go here
      });
    });
  });
</script>

Options

Options can be passed via data attributes or JavaScript.

Name Type Default Description
initial number 0 The index of the tab that should be shown on initialization.
activeClass text '' The class name(s) to apply to the active tab link.
template string
null
null The name of the micro-template to use.
templateData object {} Additional data to provide to the template rendering function.

When using data attributes, append the option name to data- and use kebab case instead of camel case. For example, data-template="my-custom-tabs" instructs the extension to use the custom my-custom-tabs template when rendering the tabs.

Events

Name Description
tabs:render Fires when the tabs markup has been rendered and inserted into the DOM.
tab:show Fires when a tab is about to be shown.
tab:shown Fires after a tab has been shown.
tab:hide Fires when a tab is about to be hidden.
tab:hidden Fires after a tab has been hidden.

Because the original list element is replaced with the HTML from the template, the event contains a reference to the new element:

document.addEventListener('tabs:render', function(e) {
  
  // The newly rendered tabs element
  var tabs = e.detail.relatedTarget;
});

Related extensions

Animations and transitions Free

Animations and transitions

Add engaging animation and transition effects to elements.

Carousels Free

Carousels

Present content in well defined and easy to follow steps.

Content blocks and icons Free

Content blocks and icons

Display icons against categories, sections and articles.