Tabbed List Template

An accessible tabbed interface that lets users switch between different lists of content.

This is a highly effective pattern for organizing categorized content, such as different types of services, product features, or pricing plans, without cluttering the page.

A screenshot of a tabbed interface with several tabs and the active tab's content showing below.

Get Source Code Preview

About this Template

This component provides a fully accessible tabbed interface, following WAI-ARIA best practices. The structure consists of a list of tab buttons that control the visibility of corresponding content panels. The state of the tabs (e.g., which one is currently selected) is managed with JavaScript, which updates the appropriate ARIA attributes and CSS classes.

Features

Code Breakdown

The component is wrapped in a main div. The tabs themselves are in a div with role="tablist", and each tab is a button with role="tab". Each tab button has an aria-controls attribute that points to the id of the content panel it controls.

The content panels are located in a separate container. Each panel is a div with role="tabpanel". By default, all but the first panel are hidden.

The JavaScript adds a click event listener to the tablist. When a tab is clicked, the script first deactivates all other tabs and hides all other panels. Then, it activates the clicked tab (by setting aria-selected="true" and an active class) and shows the corresponding panel by finding it via the tab's aria-controls attribute.

Code

Here's the full code for the template:

View Output