Navigation
Tab links
Links that look like tabs, for moving between views of the same section.
When to use
- For views of one list, such as "News", "Public notices" and "Publications".
- For a few pages about one thing, such as a service's "Overview", "Fees" and "How to apply".
When not to use
- For content that should all be on one page. Use headings.
- To show and hide parts of one page. GGDS has no in-page tabs; use headings, or a disclosure.
- As the main navigation. Use the header.
- For steps of a form.
How to use
- Each tab is a normal link to its own page or address, such as
?kind=news, so it works without JavaScript and can be bookmarked. - Mark the current tab with
aria-current="page". - Keep to two to five tabs, with names of one to three words.
- Keep the tabs in the same order and place on every page they appear.
- On a narrow phone the tabs stay on one line and the row scrolls sideways, so tabs at the end can be out of sight. Short names keep them all in view.
- Change the page
<title>to name the current tab, such as "Public notices – News".
Do
- Name tabs after what people will find: "Public notices".
Don't
- Add
role="tab"orrole="tablist". - Use more tabs than fit on a phone.
Accessibility
What GGDS does
- They are ordinary links, so they work with every assistive technology and without JavaScript.
- Every tab is at least 44px tall.
- The current tab is shown by more than colour: it is bold, with a thick line under it.
What you need to do
- Do not add ARIA tab roles. These are links and should be announced as links; people expect ARIA tabs to switch with arrow keys, without loading a page.
- Mark the current tab with
aria-current="page". - Name the navigation, such as
aria-label="Kinds of news". - Give each tab's page its own title (WCAG 2.4.2).
Example: Tab links
<nav class="ggds-tab-links" aria-label="Kinds of news">
<ul class="ggds-tab-links__list">
<li><a class="ggds-tab-links__link" href="?kind=all" aria-current="page">All</a></li>
<li><a class="ggds-tab-links__link" href="?kind=news">News</a></li>
<li><a class="ggds-tab-links__link" href="?kind=notices">Public notices</a></li>
<li><a class="ggds-tab-links__link" href="?kind=publications">Publications</a></li>
</ul>
</nav><nav className="ggds-tab-links" aria-label="Kinds of news">
<ul className="ggds-tab-links__list">
<li><a className="ggds-tab-links__link" href="?kind=all" aria-current="page">All</a></li>
<li><a className="ggds-tab-links__link" href="?kind=news">News</a></li>
<li><a className="ggds-tab-links__link" href="?kind=notices">Public notices</a></li>
<li><a className="ggds-tab-links__link" href="?kind=publications">Publications</a></li>
</ul>
</nav>Use it
- Stylesheet
ggds.cssincludes it. To load only the parts you use:core.css, thencomponents/navigation.css(0.9 KB with gzip, minified), which also holds breadcrumbs, pagination and tab links.- JavaScript
- None needed.
HTML
Copy the HTML under each example above. It works in any website.
Astro
No Astro component: copy the HTML.
React and Next.js
No React component: switch the HTML under an example to JSX (React) and copy it.
Django
No template tag: copy the HTML into your template.
Classes and states
| Class | What it does |
|---|---|
.ggds-tab-links | The <nav>, with a line under the tabs. |
.ggds-tab-links__list | The tabs. Scrolls sideways when they do not fit. |
.ggds-tab-links__link | A tab: a link to its own page. |
| State | What it does |
|---|---|
aria-current="page" on .ggds-tab-links__link | The current tab: bold, with a thick line under it. |
Accessibility tests
Automated, on every change
These run each time GGDS changes. A change that fails one is not accepted.
- WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
- No sideways scrolling on a 320px screen, also with a wide font, on every example
- Every approved colour pair meets its contrast minimum, for every institution theme
- No inline scripts or styles, so it runs under a strict Content Security Policy
By people, with assistive technology
Automated tests find only some of the barriers people meet. These checks are still to be done.
| Check | Result | Notes |
|---|---|---|
| Keyboard only | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| NVDA screen reader with Firefox or Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| JAWS screen reader with Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| VoiceOver screen reader with Safari (iPhone) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| TalkBack screen reader with Chrome (Android) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Zoom to 400%, and increased text spacing | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Windows contrast themes (forced colours) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Voice control (Voice Access or Dragon) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
Changes
| Version | Change |
|---|---|
| 0.2.0 | Fuller guidance for tags, breadcrumbs, disclosures, the skip link, pagination, rich text, tables and tab links. |
| 0.1.0 | Added. |
Related components
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.