Components

Service navigation

Service navigation helps users understand that they’re using your service and lets them navigate around your service.

WCAG 2.2

New WCAG 2.2 criteria affect this component

To use ‘Service navigation’ and meet the new Web Content Accessibility Guidelines (WCAG) 2.2 criteria, make sure that users can successfully:

See the full list of components and patterns affected by WCAG 2.2.

<div class="govuk-service-navigation"
  data-module="govuk-service-navigation">
  <div class="govuk-width-container">
    <div class="govuk-service-navigation__container">
      <nav aria-label="Menu" class="govuk-service-navigation__wrapper">
        <button type="button" class="govuk-service-navigation__toggle govuk-js-service-navigation-toggle" aria-controls="navigation" hidden>
          Menu
        </button>
        <ul class="govuk-service-navigation__list" id="navigation">
          <li class="govuk-service-navigation__item">
            <a class="govuk-service-navigation__link" href="#">
              Navigation item 1
            </a>
          </li>
          <li class="govuk-service-navigation__item govuk-service-navigation__item--active">
            <a class="govuk-service-navigation__link" href="#" aria-current="true">
              <strong class="govuk-service-navigation__active-fallback">Navigation item 2</strong>
            </a>
          </li>
          <li class="govuk-service-navigation__item">
            <a class="govuk-service-navigation__link" href="#">
              Navigation item 3
            </a>
          </li>
        </ul>
      </nav>
    </div>
  </div>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as “Required” in the option description.

If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
classes string Classes to add to the service navigation container.
attributes object HTML attributes (for example, data attributes) to add to the service navigation container.
ariaLabel string The text for the aria-label which labels the service navigation container when a service name is included. Defaults to "Service information".
menuButtonText string The text of the mobile navigation menu toggle.
menuButtonLabel string The screen reader label for the mobile navigation menu toggle. Defaults to the same value as menuButtonText if not specified.
navigationLabel string The screen reader label for the mobile navigation menu. Defaults to the same value as menuButtonText if not specified.
navigationId string The ID used to associate the mobile navigation toggle with the navigation menu. Defaults to navigation.
navigationClasses string Classes to add to the navigation menu container.
serviceName string The name of your service.
serviceUrl string The homepage of your service.
navigation array Required. Used to add navigation to the service header. See navigation.
slots object Specified points for injecting custom HTML into the service header. See slots.
Options for navigation array objects
Name Type Description
current boolean If true, indicates that the user is currently on this page. This takes precedence over active.
active boolean If true, indicates that the user is within this group of pages in the navigation hierarchy.
html string Required. HTML for the navigation item. If html is provided, the text option will be ignored.
text string Required. Text for the navigation item. If html is provided, the text option will be ignored.
href string URL of the navigation item anchor.
attributes object HTML attributes (for example data attributes) to add to the navigation item anchor.
Options for slots object
Name Type Description
start string HTML injected at the start of the service header container.
end string HTML injected at the end of the service header container.
navigationStart string HTML injected before the first list item in the navigation list. Requires navigation to be set.
navigationEnd string HTML injected after the last list item in the navigation list. Requires navigation to be set.
{% from "govuk/components/service-navigation/macro.njk" import govukServiceNavigation %}

{{ govukServiceNavigation({
  navigation: [
    {
      href: "#",
      text: "Navigation item 1"
    },
    {
      href: "#",
      text: "Navigation item 2",
      active: true
    },
    {
      href: "#",
      text: "Navigation item 3"
    }
  ]
}) }}

When to use this component

Use the Service navigation to help users understand that they’re using your service.

To decide when to use navigation links in your service, see the ‘Help users to navigate a service’ pattern.

How it works

Together, the GOV.UK header and Service navigation components ensure users get a consistent experience on GOV.UK.

This also assures users that they’re in the right place to use your service and to understand that GOV.UK functions as one website.

For guidance on how to plan your header and navigation, see the Help users navigate a service pattern.

Change the blue colour bar under the GOV.UK header to full width

To use the GOV.UK header and Service navigation and make them fit together visually, you’ll need to change the bottom blue border of the GOV.UK header to full width.

Apply a class govuk-header--full-width-border to the GOV.UK header.

<header class="govuk-header govuk-header--full-width-border" data-module="govuk-header">
  <div class="govuk-header__container govuk-width-container">
    <div class="govuk-header__logo">
      <a href="/" class="govuk-header__link govuk-header__link--homepage">
        <svg
          focusable="false"
          role="img"
          class="govuk-header__logotype"
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 148 30"
          height="30"
          width="148"
          aria-label="GOV.UK">
          <title>GOV.UK</title>
          <path d="M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 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1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z"></path>
        </svg>
      </a>
    </div>
  </div>
</header>
<div class="govuk-service-navigation"
  data-module="govuk-service-navigation">
  <div class="govuk-width-container">
    <div class="govuk-service-navigation__container">
      <nav aria-label="Menu" class="govuk-service-navigation__wrapper">
        <button type="button" class="govuk-service-navigation__toggle govuk-js-service-navigation-toggle" aria-controls="navigation" hidden>
          Menu
        </button>
        <ul class="govuk-service-navigation__list" id="navigation">
          <li class="govuk-service-navigation__item">
            <a class="govuk-service-navigation__link" href="#">
              Navigation item 1
            </a>
          </li>
          <li class="govuk-service-navigation__item govuk-service-navigation__item--active">
            <a class="govuk-service-navigation__link" href="#" aria-current="true">
              <strong class="govuk-service-navigation__active-fallback">Navigation item 2</strong>
            </a>
          </li>
          <li class="govuk-service-navigation__item">
            <a class="govuk-service-navigation__link" href="#">
              Navigation item 3
            </a>
          </li>
        </ul>
      </nav>
    </div>
  </div>
</div>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as “Required” in the option description.

If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
classes string Classes to add to the service navigation container.
attributes object HTML attributes (for example, data attributes) to add to the service navigation container.
ariaLabel string The text for the aria-label which labels the service navigation container when a service name is included. Defaults to "Service information".
menuButtonText string The text of the mobile navigation menu toggle.
menuButtonLabel string The screen reader label for the mobile navigation menu toggle. Defaults to the same value as menuButtonText if not specified.
navigationLabel string The screen reader label for the mobile navigation menu. Defaults to the same value as menuButtonText if not specified.
navigationId string The ID used to associate the mobile navigation toggle with the navigation menu. Defaults to navigation.
navigationClasses string Classes to add to the navigation menu container.
serviceName string The name of your service.
serviceUrl string The homepage of your service.
navigation array Required. Used to add navigation to the service header. See navigation.
slots object Specified points for injecting custom HTML into the service header. See slots.
Options for navigation array objects
Name Type Description
current boolean If true, indicates that the user is currently on this page. This takes precedence over active.
active boolean If true, indicates that the user is within this group of pages in the navigation hierarchy.
html string Required. HTML for the navigation item. If html is provided, the text option will be ignored.
text string Required. Text for the navigation item. If html is provided, the text option will be ignored.
href string URL of the navigation item anchor.
attributes object HTML attributes (for example data attributes) to add to the navigation item anchor.
Options for slots object
Name Type Description
start string HTML injected at the start of the service header container.
end string HTML injected at the end of the service header container.
navigationStart string HTML injected before the first list item in the navigation list. Requires navigation to be set.
navigationEnd string HTML injected after the last list item in the navigation list. Requires navigation to be set.
{% from "govuk/components/header/macro.njk" import govukHeader %}
{% from "govuk/components/service-navigation/macro.njk" import govukServiceNavigation %}

{{ govukHeader({
  classes: "govuk-header--full-width-border"
}) }}
{{ govukServiceNavigation({
  navigation: [
    {
      href: "#",
      text: "Navigation item 1"
    },
    {
      href: "#",
      text: "Navigation item 2",
      active: true
    },
    {
      href: "#",
      text: "Navigation item 3"
    }
  ]
}) }}

Showing your service name only

We recommend that you use the Service navigation component to show your service name, instead of the GOV.UK header, and to start updating existing services.

<section aria-label="Service information" class="govuk-service-navigation"
  data-module="govuk-service-navigation">
  <div class="govuk-width-container">
    <div class="govuk-service-navigation__container">
      <span class="govuk-service-navigation__service-name">
        <a href="#" class="govuk-service-navigation__link">
          Service name
        </a>
      </span>
    </div>
  </div>
</section>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as “Required” in the option description.

If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
classes string Classes to add to the service navigation container.
attributes object HTML attributes (for example, data attributes) to add to the service navigation container.
ariaLabel string The text for the aria-label which labels the service navigation container when a service name is included. Defaults to "Service information".
menuButtonText string The text of the mobile navigation menu toggle.
menuButtonLabel string The screen reader label for the mobile navigation menu toggle. Defaults to the same value as menuButtonText if not specified.
navigationLabel string The screen reader label for the mobile navigation menu. Defaults to the same value as menuButtonText if not specified.
navigationId string The ID used to associate the mobile navigation toggle with the navigation menu. Defaults to navigation.
navigationClasses string Classes to add to the navigation menu container.
serviceName string The name of your service.
serviceUrl string The homepage of your service.
navigation array Required. Used to add navigation to the service header. See navigation.
slots object Specified points for injecting custom HTML into the service header. See slots.
Options for navigation array objects
Name Type Description
current boolean If true, indicates that the user is currently on this page. This takes precedence over active.
active boolean If true, indicates that the user is within this group of pages in the navigation hierarchy.
html string Required. HTML for the navigation item. If html is provided, the text option will be ignored.
text string Required. Text for the navigation item. If html is provided, the text option will be ignored.
href string URL of the navigation item anchor.
attributes object HTML attributes (for example data attributes) to add to the navigation item anchor.
Options for slots object
Name Type Description
start string HTML injected at the start of the service header container.
end string HTML injected at the end of the service header container.
navigationStart string HTML injected before the first list item in the navigation list. Requires navigation to be set.
navigationEnd string HTML injected after the last list item in the navigation list. Requires navigation to be set.
{% from "govuk/components/service-navigation/macro.njk" import govukServiceNavigation %}

{{ govukServiceNavigation({
  serviceName: "Service name",
  serviceUrl: "#"
}) }}

Show navigation links to let users navigate to different parts of your service and find useful links and tools.

<section aria-label="Service information" class="govuk-service-navigation"
  data-module="govuk-service-navigation">
  <div class="govuk-width-container">
    <div class="govuk-service-navigation__container">
      <span class="govuk-service-navigation__service-name">
        <a href="#" class="govuk-service-navigation__link">
          Service name
        </a>
      </span>
      <nav aria-label="Menu" class="govuk-service-navigation__wrapper">
        <button type="button" class="govuk-service-navigation__toggle govuk-js-service-navigation-toggle" aria-controls="navigation" hidden>
          Menu
        </button>
        <ul class="govuk-service-navigation__list" id="navigation">
          <li class="govuk-service-navigation__item">
            <a class="govuk-service-navigation__link" href="#">
              Navigation item 1
            </a>
          </li>
          <li class="govuk-service-navigation__item govuk-service-navigation__item--active">
            <a class="govuk-service-navigation__link" href="#" aria-current="true">
              <strong class="govuk-service-navigation__active-fallback">Navigation item 2</strong>
            </a>
          </li>
          <li class="govuk-service-navigation__item">
            <a class="govuk-service-navigation__link" href="#">
              Navigation item 3
            </a>
          </li>
        </ul>
      </nav>
    </div>
  </div>
</section>
Nunjucks macro options

Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.

Some options are required for the macro to work; these are marked as “Required” in the option description.

If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against cross-site scripting exploits.

Primary options
Name Type Description
classes string Classes to add to the service navigation container.
attributes object HTML attributes (for example, data attributes) to add to the service navigation container.
ariaLabel string The text for the aria-label which labels the service navigation container when a service name is included. Defaults to "Service information".
menuButtonText string The text of the mobile navigation menu toggle.
menuButtonLabel string The screen reader label for the mobile navigation menu toggle. Defaults to the same value as menuButtonText if not specified.
navigationLabel string The screen reader label for the mobile navigation menu. Defaults to the same value as menuButtonText if not specified.
navigationId string The ID used to associate the mobile navigation toggle with the navigation menu. Defaults to navigation.
navigationClasses string Classes to add to the navigation menu container.
serviceName string The name of your service.
serviceUrl string The homepage of your service.
navigation array Required. Used to add navigation to the service header. See navigation.
slots object Specified points for injecting custom HTML into the service header. See slots.
Options for navigation array objects
Name Type Description
current boolean If true, indicates that the user is currently on this page. This takes precedence over active.
active boolean If true, indicates that the user is within this group of pages in the navigation hierarchy.
html string Required. HTML for the navigation item. If html is provided, the text option will be ignored.
text string Required. Text for the navigation item. If html is provided, the text option will be ignored.
href string URL of the navigation item anchor.
attributes object HTML attributes (for example data attributes) to add to the navigation item anchor.
Options for slots object
Name Type Description
start string HTML injected at the start of the service header container.
end string HTML injected at the end of the service header container.
navigationStart string HTML injected before the first list item in the navigation list. Requires navigation to be set.
navigationEnd string HTML injected after the last list item in the navigation list. Requires navigation to be set.
{% from "govuk/components/service-navigation/macro.njk" import govukServiceNavigation %}

{{ govukServiceNavigation({
  serviceName: "Service name",
  serviceUrl: "#",
  navigation: [
    {
      href: "#",
      text: "Navigation item 1"
    },
    {
      href: "#",
      text: "Navigation item 2",
      active: true
    },
    {
      href: "#",
      text: "Navigation item 3"
    }
  ]
}) }}

See when and how to show navigation links in the Help users navigate a service pattern.

WCAG 2.2

Do not make header elements, like dropdown menus, ‘sticky’ to the top of the page by using `position: fixed` or any other method. In other words, avoid any implementations that cause menus to sit on top of page content.

This is to make sure elements do not hide or obscure any content which has a focus applied and comply with WCAG 2.2 success criterion 2.4.11 Focus not obscured (minimum).

In November 2021, the GOV.UK homepage introduced a menu bar that avoids obscuring content by shifting the page down.

Use ‘slots’ to add custom elements

The Service navigation includes the option to use ‘slots’ to insert custom HTML code at specific points inside the component. This helps you extend the component to add custom elements, such as language selectors.

You must provide your own styles and JavaScript code for the content within a slot, particularly if you’re not using an existing component. You’ll need to decide on the most appropriate layout and positioning.

The Help users to navigate a service pattern includes some guidance on ‘Adding other header and navigation elements’.

Ensure the ‘aria-label’ is accurate for users of assistive technology

When a service name is shown, we let users know that there’s information about the service with a ‘region landmark’ using the <section> element.

Depending on what you add in the slots, you might need to rename the aria-label to accurately describe what’s in the section.

Test with each update of GOV.UK Frontend

There’s a risk that slot contents may look or work differently in a future release of GOV.UK Frontend.

You’ll need to ensure that slot content still works as intended after each update.

Research on this component

See the research section in the Help users navigate a service pattern for a summary of our research on the GOV.UK header and Service navigation, and how you can share your feedback with us.

Help improve this component

To help make sure that this page is useful, relevant and up to date, you can:

Tell us if your service uses this component

Take part in our usage survey (opens in a new tab) to help us improve this component to better meet the needs of the services that use it.

Need help?

If you’ve got a question about the GOV.UK Design System, contact the team.