Tabs group related content into panels that visitors can switch between without losing their place. Add them straight from the Zendesk article editor toolbar, and our themes style them to match the rest of your help center.
Tabs make it easier for visitors to find what they’re after by grouping related content, such as instructions for different operating systems, products or roles. The Zendesk article editor now includes native tabs that you can add and edit straight from the toolbar, and our themes style them to match the rest of your help center. We recommend using them for all new content.
The list-based tabs used in earlier versions of our themes are still supported, so existing articles don’t need to change. You’ll find their instructions in the Legacy elements tab.
Native article components are supported in version 4.0.0 or later of our themes. If you’re using an earlier version, use the legacy elements instead.
Adding tabs
Create a new article or edit an existing one in your help center or Knowledge admin, and place your cursor where the tabs should appear.
Click the Article components button in the editor toolbar and select Tabs.
Enter a short title for the first tab, followed by its content. You can format the content using the editor toolbar as usual.
Click the Add tab icon (+) in the tabs toolbar to add another tab. Use the Move up and Move down icons to reorder tabs, and the Remove icon to delete one.
Expand the tab that should be selected when the page loads. Visitors will see this tab first.
Click Save.
To move a tab group, hover over it and drag the handle. To remove it, click the handle to select the group and press Delete. You can add as many tab groups to an article as you need.
Native tabs
<zd-tabs> <div class="wysiwyg-disclosure wysiwyg-tabs"> <details open> <summary>Android</summary> <div class="wysiwyg-disclosure-content"> <p>Open the <strong>Settings</strong> app and tap <strong>Notifications</strong>.</p> </div> </details> <details> <summary>iOS</summary> <div class="wysiwyg-disclosure-content"> <p>Open <strong>Settings</strong>, then tap <strong>Notifications</strong> and choose the app.</p> </div> </details> <details> <summary>Windows</summary> <div class="wysiwyg-disclosure-content"> <p>Select <strong>Start</strong>, then <strong>Settings</strong> > <strong>System</strong> > <strong>Notifications</strong>.</p> </div> </details> </div></zd-tabs>
The editor creates this markup for you. Each tab is a <details> element with a <summary> for its title, which Zendesk turns into a tab bar when the page loads. If scripts are unavailable, visitors still see every tab’s content in order.
Linking to a tab
A link to the id of any element inside a tab, such as a heading, selects that tab and scrolls to the element. This makes it possible to link visitors straight to the instructions that apply to them.
Styling tabs
The tab color, border color, border width, corner radius and margin can be changed in the Tabs section of the visual builder’s Formatting elements panel.
You can also write your own custom CSS, for example:
/* Change the color of the selected tab to red */.content .wysiwyg-tabs-active { --zd-wysiwyg-tabs-color: red;}/* Change the color of text in a tab to blue */.content .wysiwyg-tabs .wysiwyg-disclosure-content { color: blue;}
Adding legacy tabs to article content
Because the tabs script is built into all of our themes, there are no additional scripts to include or code to write.
The first step is to create a numbered or bulleted list in your article where each list item contains the content that will be contained within its own tab. If you have a lot of content to display in each tab, or content that contains headings and other custom elements, we recommend using the HTML (source code) view within the article editor.
The list itself will be a <ol> or <ul> element, with child list items represented as <li> elements.
Once you’ve added all of your content to the list add a class name of .js-tabs to the list and a title attribute to each list item. For example:
<ul class="js-tabs"> <li title="The first tab title">...</li> <li title="The second tab title">...</li> <li title="The third tab title">...</li></ul>
Where:
The .js-tabs class name specifies that we’d like to convert this list into dynamic tabs.
The title attribute specifies the title for each tab.
The content of each list item is converted into its own tab.
This approach ensures a separation between your content and how it’s displayed to visitors. If you ever decide to disable tabs for a given list, change themes or export your content you’ll see a simple, uncontaminated list.
In version 4.0.0 of our themes you can also use data-element="tabs" in place of the class name, and give a tab its title with a data-title attribute or a heading with the .tab-heading class instead of the title attribute. Legacy tabs are rendered using the same markup as native tabs, so both look identical in your help center.
Styling legacy tabs
Because legacy tabs are rendered using the same markup as native tabs, they pick up the same styles, including those set in the visual builder. The custom CSS examples in the Article components tab apply to both.
Using a custom micro-template
For the more adventurous among you, you can create your own custom micro-template. A custom template replaces the default rendering for both native and legacy tabs.
A custom template allows you to change not just the appearance of the tabs, but their underlying HTML structure and behavior. Below is an example of a custom tabs template that you could use that not only changes the size and appearance of the tabs, but introduces custom icons:
Large, justified tabs with icons
<ul class="nav nav-tabs nav-justified"> <li class="nav-item bg-white sm:bg-transparent"> <a class="nav-link flex align-items-center justify-content-center font-semibold font-size-lg text-gray-700 px-2 py-4 hover:text-gray-800 hover:bg-gray-100 is-active bg-gray-100 md:bg-transparent is-shown" data-toggle="tab" data-active-class="bg-gray-100 md:bg-transparent" aria-expanded="true" href="#tab-1"> <svg class="fill-current mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"> <path d="M 7.5 1 C 7.372 1 7.2439844 1.0489844 7.1464844 1.1464844 C 6.9514844 1.3414844 6.9514844 1.6585156 7.1464844 1.8535156 L 8.4570312 3.1640625 C 6.9691108 4.2559188 6 6.0127547 6 8 L 18 8 C 18 6.0127547 17.030889 4.2559188 15.542969 3.1640625 L 16.853516 1.8535156 C 17.048516 1.6575156 17.048516 1.3424844 16.853516 1.1464844 C 16.658516 0.95148437 16.341484 0.95148438 16.146484 1.1464844 L 14.664062 2.6289062 C 13.860616 2.2295595 12.95819 2 12 2 C 11.04181 2 10.139384 2.2295595 9.3359375 2.6289062 L 7.8535156 1.1464844 C 7.7560156 1.0489844 7.628 1 7.5 1 z M 9 5 L 10 5 L 10 6 L 9 6 L 9 5 z M 14 5 L 15 5 L 15 6 L 14 6 L 14 5 z M 4 9 C 3.448 9 3 9.448 3 10 L 3 16 C 3 16.552 3.448 17 4 17 C 4.552 17 5 16.552 5 16 L 5 10 C 5 9.448 4.552 9 4 9 z M 6 9 L 6 17 C 6 17.552 6.448 18 7 18 L 8 18 L 8 21.5 C 8 22.328 8.672 23 9.5 23 C 10.328 23 11 22.328 11 21.5 L 11 18 L 13 18 L 13 21.5 C 13 22.328 13.672 23 14.5 23 C 15.328 23 16 22.328 16 21.5 L 16 18 L 17 18 C 17.552 18 18 17.552 18 17 L 18 9 L 6 9 z M 20 9 C 19.448 9 19 9.448 19 10 L 19 16 C 19 16.552 19.448 17 20 17 C 20.552 17 21 16.552 21 16 L 21 10 C 21 9.448 20.552 9 20 9 z"/> </svg> Android </a> </li> <li class="nav-item bg-white sm:bg-transparent"> <a class="nav-link flex align-items-center justify-content-center font-semibold font-size-lg text-gray-700 px-2 py-4 hover:text-gray-800 hover:bg-gray-100" data-toggle="tab" data-active-class="bg-gray-100 md:bg-transparent" aria-expanded="true" href="#tab-2"> <svg class="fill-current mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"> <path d="M 7.5332031 2.9765625 C 5.0249242 2.9765625 2.9765625 5.0249242 2.9765625 7.5332031 L 2.9765625 16.421875 C 2.9765625 18.930154 5.0249242 20.978516 7.5332031 20.978516 L 16.421875 20.978516 C 18.930154 20.978516 20.978516 18.930154 20.978516 16.421875 L 20.978516 7.5332031 C 20.978516 5.0249242 18.930154 2.9765625 16.421875 2.9765625 L 7.5332031 2.9765625 z M 7.5332031 4.9765625 L 16.421875 4.9765625 C 17.861596 4.9765625 18.978516 6.0934821 18.978516 7.5332031 L 18.978516 16.421875 C 18.978516 17.861596 17.861596 18.978516 16.421875 18.978516 L 7.5332031 18.978516 C 6.0934821 18.978516 4.9765625 17.861596 4.9765625 16.421875 L 4.9765625 7.5332031 C 4.9765625 6.0934821 6.0934821 4.9765625 7.5332031 4.9765625 z M 6.5 9 A 0.5 0.5 0 0 0 6 9.5 A 0.5 0.5 0 0 0 6.5 10 A 0.5 0.5 0 0 0 7 9.5 A 0.5 0.5 0 0 0 6.5 9 z M 10.5 9 C 8.961 9 8 10.152 8 12 C 8 13.844 8.943 15 10.5 15 C 12.053 15 13 13.84 13 12 C 13 10.156 12.046 9 10.5 9 z M 16 9 C 15.442109 9 14.930338 9.180727 14.564453 9.5292969 C 14.198568 9.8778668 14 10.382639 14 10.927734 C 14 11.458086 14.353792 11.887411 14.726562 12.091797 C 15.099334 12.296183 15.501273 12.382761 15.869141 12.482422 C 16.254472 12.586815 16.604109 12.681691 16.792969 12.785156 C 16.981829 12.888622 17 12.891871 17 13.072266 C 17 13.388803 16.9031 13.598546 16.746094 13.748047 C 16.589087 13.897548 16.350292 14 16 14 C 15.676119 14 15.434132 13.906951 15.273438 13.757812 C 15.112742 13.608676 15 13.390833 15 13 L 14 13 C 14 13.609167 14.215695 14.141325 14.59375 14.492188 C 14.971805 14.843049 15.478881 15 16 15 C 16.557708 15 17.069553 14.821155 17.435547 14.472656 C 17.801541 14.124157 18 13.617728 18 13.072266 C 18 12.54166 17.646328 12.112488 17.273438 11.908203 C 16.900547 11.703918 16.498528 11.617185 16.130859 11.517578 C 15.745727 11.413239 15.396009 11.318458 15.207031 11.214844 C 15.018053 11.11123 15 11.107382 15 10.927734 C 15 10.61183 15.096791 10.401633 15.253906 10.251953 C 15.411022 10.102273 15.649891 10 16 10 C 16.323881 10 16.565867 10.093049 16.726562 10.242188 C 16.887258 10.391324 17 10.609167 17 11 L 18 11 C 18 10.390833 17.784305 9.8586753 17.40625 9.5078125 C 17.028195 9.1569497 16.521119 9 16 9 z M 10.5 10 C 11.805 10 12 11.253 12 12 C 12 12.747 11.805 14 10.5 14 C 9.26 14 9 12.912 9 12 C 9 11.253 9.195 10 10.5 10 z M 6 11 L 6 15 L 7 15 L 7 11 L 6 11 z"/> </svg> iOS </a> </li> <li class="nav-item bg-white sm:bg-transparent"> <a class="nav-link flex align-items-center justify-content-center font-semibold font-size-lg text-gray-700 px-2 py-4 hover:text-gray-800 hover:bg-gray-100" data-toggle="tab" data-active-class="bg-gray-100 md:bg-transparent" aria-expanded="true" href="#tab-3"> <svg class="fill-current mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"> <path d="M 19.09375 2.0019531 C 18.948812 1.9952031 18.8025 2.0040469 18.65625 2.0292969 L 12 3.1894531 L 12 11 L 21 11 L 21 4 C 21 3.408 20.740109 2.84975 20.287109 2.46875 C 19.947359 2.183 19.528562 2.0222031 19.09375 2.0019531 z M 10 3.5371094 L 4.65625 4.46875 C 3.69725 4.63675 3 5.4654531 3 6.4394531 L 3 11 L 10 11 L 10 3.5371094 z M 3 13 L 3 17.560547 C 3 18.534547 3.69725 19.36325 4.65625 19.53125 L 10 20.462891 L 10 13 L 3 13 z M 12 13 L 12 20.810547 L 18.65625 21.970703 C 18.77125 21.990703 18.886953 22 19.001953 22 C 19.468953 22 19.923109 21.835297 20.287109 21.529297 C 20.740109 21.148297 21 20.591 21 20 L 21 13 L 12 13 z"/> </svg> Windows </a> </li> </ul><div class="tabs"> <div class="tab list-unstyled p-6 bg-white border border-radius-bottom fade is-active is-shown" id="tab-1" role="tab-panel"> <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> </div> <div class="tab list-unstyled p-6 bg-white border border-radius-bottom fade" id="tab-2" role="tab-panel"> <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> </div> <div class="tab list-unstyled p-6 bg-white border border-radius-bottom fade" id="tab-3" role="tab-panel"> <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 connect devices to an external display and use a desktop interface with mouse and keyboard input support.</p> </div></div>
An optional fade effect can be added by using .fade on each tab. If the fade effect is applied the active tab must also have .is-shown in order to be visible.
Version 4.0.0 of our themes includes a ready-made tabs template, commented out, in the Document head template (document_head.hbs). Remove the comment tags around the tmpl-tabs template to use it as a starting point. The tabs script looks for a micro-template with an id of tabs by default, so adding one to the Document head, Article page (article_page.hbs) or Footer (footer.hbs) template will ensure that it’s used for all tabs within your article content.
The template receives the tab group’s id, the index of the initial tab, the activeClass and a list of children. Each child has an id, a title and the tab’s content as innerHTML, whether the tab group was created with the article editor or as a legacy list.
Questions or feedback about this article? Let us know