Components

Tabs

Experimental

This component is currently experimental because more research is needed to validate it.

The tabs component lets users navigate between related sections of content, displaying one section at a time.

Contents

Past day

Case manager Cases opened Cases closed
David Francis 3 0
Paul Farmer 1 0
Rita Patel 2 0

Past week

Case manager Cases opened Cases closed
David Francis 24 18
Paul Farmer 16 20
Rita Patel 24 27

Past month

Case manager Cases opened Cases closed
David Francis 98 95
Paul Farmer 122 131
Rita Patel 126 142

Past year

Case manager Cases opened Cases closed
David Francis 1380 1472
Paul Farmer 1129 1083
Rita Patel 1539 1265
<div class="govuk-tabs">
  <h2 class="govuk-tabs__title">Contents</h2>
  <ul class="govuk-tabs__list" role="tablist">
    <li
      class="govuk-tabs__list-item govuk-tabs__list-item--selected"
      role="presentation"
    >
      <a
        aria-controls="past-day"
        aria-selected="true"
        class="govuk-tabs__tab"
        href="#past-day"
        id="tab_past-day"
        role="tab"
      >
        Past day
      </a>
    </li>
    <li
      class="govuk-tabs__list-item"
      role="presentation"
    >
      <a
        aria-controls="past-week"
        aria-selected="false"
        class="govuk-tabs__tab"
        href="#past-week"
        id="tab_past-week"
        role="tab"
      >
        Past week
      </a>
    </li>
    <li
      class="govuk-tabs__list-item"
      role="presentation"
    >
      <a
        aria-controls="past-month"
        aria-selected="false"
        class="govuk-tabs__tab"
        href="#past-month"
        id="tab_past-month"
        role="tab"
      >
        Past month
      </a>
    </li>
    <li
      class="govuk-tabs__list-item"
      role="presentation"
    >
      <a
        aria-controls="past-year"
        aria-selected="false"
        class="govuk-tabs__tab"
        href="#past-year"
        id="tab_past-year"
        role="tab"
      >
        Past year
      </a>
    </li>
  </ul>
  <div
    aria-labelledby="tab_past-day"
    class="govuk-tabs__panel"
    id="past-day"
    role="tabpanel"
  >
    <h2>Past day</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">3</td>
          <td class="govuk-table__cell">0</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">1</td>
          <td class="govuk-table__cell">0</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">2</td>
          <td class="govuk-table__cell">0</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div
    aria-labelledby="tab_past-week"
    class="govuk-tabs__panel"
    id="past-week"
    role="tabpanel"
  >
    <h2>Past week</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">24</td>
          <td class="govuk-table__cell">18</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">16</td>
          <td class="govuk-table__cell">20</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">24</td>
          <td class="govuk-table__cell">27</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div
    aria-labelledby="tab_past-month"
    class="govuk-tabs__panel"
    id="past-month"
    role="tabpanel"
  >
    <h2>Past month</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">98</td>
          <td class="govuk-table__cell">95</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">122</td>
          <td class="govuk-table__cell">131</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">126</td>
          <td class="govuk-table__cell">142</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div
    aria-labelledby="tab_past-year"
    class="govuk-tabs__panel"
    id="past-year"
    role="tabpanel"
  >
    <h2>Past year</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">1380</td>
          <td class="govuk-table__cell">1472</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">1129</td>
          <td class="govuk-table__cell">1083</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">1539</td>
          <td class="govuk-table__cell">1265</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
<Tabs
  items={[
    {
      label: "Past day",
      id: "past-day",
      content: (
        <Fragment>
          <h2>Past day</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "3",
                closed: "0",
              },
              {
                manager: "Paul Farmer",
                opened: "1",
                closed: "0",
              },
              {
                manager: "Rita Patel",
                opened: "2",
                closed: "0",
              },
            ]}
          />
        </Fragment>
      ),
    },
    {
      label: "Past week",
      id: "past-week",
      content: (
        <Fragment>
          <h2>Past week</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "24",
                closed: "18",
              },
              {
                manager: "Paul Farmer",
                opened: "16",
                closed: "20",
              },
              {
                manager: "Rita Patel",
                opened: "24",
                closed: "27",
              },
            ]}
          />
        </Fragment>
      ),
    },
    {
      label: "Past month",
      id: "past-month",
      content: (
        <Fragment>
          <h2>Past month</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "98",
                closed: "95",
              },
              {
                manager: "Paul Farmer",
                opened: "122",
                closed: "131",
              },
              {
                manager: "Rita Patel",
                opened: "126",
                closed: "142",
              },
            ]}
          />
        </Fragment>
      ),
    },
    {
      label: "Past year",
      id: "past-year",
      content: (
        <Fragment>
          <h2>Past year</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "1380",
                closed: "1472",
              },
              {
                manager: "Paul Farmer",
                opened: "1129",
                closed: "1083",
              },
              {
                manager: "Rita Patel",
                opened: "1539",
                closed: "1265",
              },
            ]}
          />
        </Fragment>
      ),
    },
  ]}
/>
Props
Name Type Default Description
id string - 'id' attribute to place on the base HTML element
classBlock string - Block name override in BEM style classes applied to all elements
classModifiers other - BEM style modifiers to apply to the base HTML element
className string - Extra classes to apply to the base HTML element
items other - REQUIRED.
title string Contents

When to use this component

Tabs can be a helpful way of letting users quickly switch between related information if:

  • your content can be usefully separated into clearly labelled sections
  • the first section is more relevant than the others for most users
  • users will not need to view all the sections at once

Tabs can work well for people who use a service regularly, for example, users of a caseworking system. Their need to perform tasks quickly may be greater than their need for simplicity of first-time use.

When not to use this component

Do not use the tabs component if the total amount of content the tabs contain will make the page slow to load. For this reason, do not use the tabs component as a form of page navigation.

Tabs hide content from users and not everyone will notice them or understand how they work.

Do not use tabs if your users might need to:

  • read through all of the content in order, for example, to understand a step-by-step process
  • compare information in different tabs - having to memorise the information and switch backwards and forwards can be frustrating and difficult

Test your content without tabs first. Consider if it’s better to:

  • simplify and reduce the amount of content
  • split the content across multiple pages
  • keep the content on a single page, separated by headings
  • use a table of contents to let users navigate quickly to specific sections of content

Tabs, accordion and details

Tabs, [accordions] , and [details] all hide sections of content which a user can choose to reveal.

Consider using tabs instead of an accordion if users do not need to view more than one section at a time.

You should also take into account the number of sections of content. Tabs are arranged horizontally, so cannot fit as many sections as accordions, which display vertically.

Tabs may work better for users who need to switch quickly between 2 sections.

Accordions push other sections down the page when they open, but tabs do not move which makes it easier to switch.

Consider using tabs instead of the details component if there are multiple related sections of content. The details component might be better if you only have 1 or 2 sections of content. The details component is less visually prominent than tabs, so tends to work better for content which is not as important to users.

How it works

Contents

Past day

Case manager Cases opened Cases closed
David Francis 3 0
Paul Farmer 1 0
Rita Patel 2 0

Past week

Case manager Cases opened Cases closed
David Francis 24 18
Paul Farmer 16 20
Rita Patel 24 27

Past month

Case manager Cases opened Cases closed
David Francis 98 95
Paul Farmer 122 131
Rita Patel 126 142

Past year

Case manager Cases opened Cases closed
David Francis 1380 1472
Paul Farmer 1129 1083
Rita Patel 1539 1265
<div class="govuk-tabs">
  <h2 class="govuk-tabs__title">Contents</h2>
  <ul class="govuk-tabs__list" role="tablist">
    <li
      class="govuk-tabs__list-item govuk-tabs__list-item--selected"
      role="presentation"
    >
      <a
        aria-controls="past-day"
        aria-selected="true"
        class="govuk-tabs__tab"
        href="#past-day"
        id="tab_past-day"
        role="tab"
      >
        Past day
      </a>
    </li>
    <li
      class="govuk-tabs__list-item"
      role="presentation"
    >
      <a
        aria-controls="past-week"
        aria-selected="false"
        class="govuk-tabs__tab"
        href="#past-week"
        id="tab_past-week"
        role="tab"
      >
        Past week
      </a>
    </li>
    <li
      class="govuk-tabs__list-item"
      role="presentation"
    >
      <a
        aria-controls="past-month"
        aria-selected="false"
        class="govuk-tabs__tab"
        href="#past-month"
        id="tab_past-month"
        role="tab"
      >
        Past month
      </a>
    </li>
    <li
      class="govuk-tabs__list-item"
      role="presentation"
    >
      <a
        aria-controls="past-year"
        aria-selected="false"
        class="govuk-tabs__tab"
        href="#past-year"
        id="tab_past-year"
        role="tab"
      >
        Past year
      </a>
    </li>
  </ul>
  <div
    aria-labelledby="tab_past-day"
    class="govuk-tabs__panel"
    id="past-day"
    role="tabpanel"
  >
    <h2>Past day</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">3</td>
          <td class="govuk-table__cell">0</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">1</td>
          <td class="govuk-table__cell">0</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">2</td>
          <td class="govuk-table__cell">0</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div
    aria-labelledby="tab_past-week"
    class="govuk-tabs__panel"
    id="past-week"
    role="tabpanel"
  >
    <h2>Past week</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">24</td>
          <td class="govuk-table__cell">18</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">16</td>
          <td class="govuk-table__cell">20</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">24</td>
          <td class="govuk-table__cell">27</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div
    aria-labelledby="tab_past-month"
    class="govuk-tabs__panel"
    id="past-month"
    role="tabpanel"
  >
    <h2>Past month</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">98</td>
          <td class="govuk-table__cell">95</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">122</td>
          <td class="govuk-table__cell">131</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">126</td>
          <td class="govuk-table__cell">142</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div
    aria-labelledby="tab_past-year"
    class="govuk-tabs__panel"
    id="past-year"
    role="tabpanel"
  >
    <h2>Past year</h2>
    <table class="govuk-table">
      <thead class="govuk-table__head">
        <tr class="govuk-table__row">
          <th scope="col" class="govuk-table__header">
            Case manager
          </th>
          <th scope="col" class="govuk-table__header">
            Cases opened
          </th>
          <th scope="col" class="govuk-table__header">
            Cases closed
          </th>
        </tr>
      </thead>
      <tbody class="govuk-table__body">
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            David Francis
          </th>
          <td class="govuk-table__cell">1380</td>
          <td class="govuk-table__cell">1472</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Paul Farmer
          </th>
          <td class="govuk-table__cell">1129</td>
          <td class="govuk-table__cell">1083</td>
        </tr>
        <tr class="govuk-table__row">
          <th scope="row" class="govuk-table__header">
            Rita Patel
          </th>
          <td class="govuk-table__cell">1539</td>
          <td class="govuk-table__cell">1265</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
<Tabs
  items={[
    {
      label: "Past day",
      id: "past-day",
      content: (
        <Fragment>
          <h2>Past day</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "3",
                closed: "0",
              },
              {
                manager: "Paul Farmer",
                opened: "1",
                closed: "0",
              },
              {
                manager: "Rita Patel",
                opened: "2",
                closed: "0",
              },
            ]}
          />
        </Fragment>
      ),
    },
    {
      label: "Past week",
      id: "past-week",
      content: (
        <Fragment>
          <h2>Past week</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "24",
                closed: "18",
              },
              {
                manager: "Paul Farmer",
                opened: "16",
                closed: "20",
              },
              {
                manager: "Rita Patel",
                opened: "24",
                closed: "27",
              },
            ]}
          />
        </Fragment>
      ),
    },
    {
      label: "Past month",
      id: "past-month",
      content: (
        <Fragment>
          <h2>Past month</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "98",
                closed: "95",
              },
              {
                manager: "Paul Farmer",
                opened: "122",
                closed: "131",
              },
              {
                manager: "Rita Patel",
                opened: "126",
                closed: "142",
              },
            ]}
          />
        </Fragment>
      ),
    },
    {
      label: "Past year",
      id: "past-year",
      content: (
        <Fragment>
          <h2>Past year</h2>
          <Table
            keys={["manager", "opened", "closed"]}
            headings={{
              manager: "Case manager",
              opened: "Cases opened",
              closed: "Cases closed",
            }}
            data={[
              {
                manager: "David Francis",
                opened: "1380",
                closed: "1472",
              },
              {
                manager: "Paul Farmer",
                opened: "1129",
                closed: "1083",
              },
              {
                manager: "Rita Patel",
                opened: "1539",
                closed: "1265",
              },
            ]}
          />
        </Fragment>
      ),
    },
  ]}
/>

The tabs component uses JavaScript. When JavaScript is not available, users will see the tabbed content on a single page, in order from first to last, with a table of contents that links to each of the sections.

This is also how the component currently behaves on small screens, though more research is needed on this.

Use clear labels

Tabs hide content, so the tab labels need to make it very clear what they link to, otherwise users will not know if they need to click on them.

If you struggle to come up with clear labels, it might be because the way you’ve separated the content is not clear.

Order the tabs according to user needs

The first tab should be the most commonly-needed section. Arrange the other tabs in the order that makes most sense for your users.

Do not disable tabs

Disabling elements is normally confusing for users. If there is no content for a tab, either remove the tab or, if that would be confusing for your users, explain why there is no content when the tab is selected.

Avoid tabs that wrap over more than one line

If you use too many tabs or they have long labels then they may wrap over more than one line. This makes it harder for users to see the connection between the selected tab and its content.

Research and testing

This component is experimental because it has not yet been tried in research with users.

The design, code and guidance here are based on recommendations from Inclusive Components and the Nielsen Norman Group as well as user research findings and examples of tabs in the following services:

  • Manage bereavement support payment (DWP)
  • Support for check your state pension (DWP)
  • Access to work integrated system (DWP)
  • Bank holidays (GDS)
  • Universal Credit (DWP)
  • Criminal Justice Services (CPP)
  • Judiciary UI internal systems (HMCTS)
  • Rural Payments (Defra)

Next steps

User research is needed to confirm:

  • which types of services tabs work best in
  • that this approach to tabs is the best option for screen reader users and sighted keyboard users
  • how this component should behave on small screen sizes