Contents
<nav class="x-govuk-primary-navigation" aria-labelledby="primary-navigation-heading">
<div class="govuk-width-container">
<h2 class="govuk-visually-hidden" id="primary-navigation-heading">Navigation</h2>
<ul class="x-govuk-primary-navigation__list">
<li class="x-govuk-primary-navigation__item x-govuk-primary-navigation__item--current">
<a class="x-govuk-primary-navigation__link" aria-current=page href="#">Home</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Support</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Features</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Pricing</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Contact us</a>
</li>
</ul>
</div>
</nav>
{{ xGovukPrimaryNavigation({
visuallyHiddenTitle: "Navigation",
items: [{
text: "Home",
href: "#",
current: true
}, {
text: "Support",
href: "#"
}, {
text: "Features",
href: "#"
}, {
text: "Pricing",
href: "#"
}, {
text: "Contact us",
href: "#"
}]
}) }}
When to use this component
Use the primary navigation component to let users navigate to the main sections of your service.
You must use this component with the header component.
How it works
The primary navigation component takes up the full width of the page. To ensure there is no gap between the header and this component, create a modifying class to make the bottom border on the header also take up the full width of the page:
Only include links to top level sections within your service.
One of the items should be highlighted if it matches the current page or parent section. This item remains a link, but includes an aria-current="page"
attribute with a line displayed beneath it to indicate that it is the current section.
If your service uses the phase banner component, this should appear directly above the primary navigation component.
To ensure there is no border between the phase banner and navigation, create a modifying class to remove the bottom border from the phase banner:
Contents
<style>
.app-header--full-width-border {
border-bottom: 10px solid #1f70b8;
}
.app-phase-banner–no-border {
border-bottom: none;
}
</style>
<header class="govuk-header app-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/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4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.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-phase-banner app-phase-banner–no-border govuk-width-container">
<p class="govuk-phase-banner__content">
<strong class="govuk-tag govuk-phase-banner__content__tag">
Alpha
</strong>
<span class="govuk-phase-banner__text">
This is a new service – your <a class="govuk-link" href="#">feedback</a> will help us to improve it.
</span>
</p>
</div>
<nav class="x-govuk-primary-navigation" aria-labelledby="primary-navigation-heading">
<div class="govuk-width-container">
<h2 class="govuk-visually-hidden" id="primary-navigation-heading">Navigation</h2>
<ul class="x-govuk-primary-navigation__list">
<li class="x-govuk-primary-navigation__item x-govuk-primary-navigation__item–current">
<a class="x-govuk-primary-navigation__link" aria-current=page href="#">Home</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Support</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Features</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Pricing</a>
</li>
<li class="x-govuk-primary-navigation__item ">
<a class="x-govuk-primary-navigation__link" href="#">Contact us</a>
</li>
</ul>
</div>
</nav>
<style>
.app-header--full-width-border {
border-bottom: 10px solid #1f70b8;
}
.app-phase-banner–no-border {
border-bottom: none;
}
</style>
{{ govukHeader({
classes: "app-header–full-width-border"
}) }}
{{ govukPhaseBanner({
classes: "app-phase-banner–no-border govuk-width-container",
tag: {
text: "Alpha"
},
html: 'This is a new service – your <a class="govuk-link" href="#">feedback</a> will help us to improve it.'
}) }}
{{ xGovukPrimaryNavigation({
visuallyHiddenTitle: "Navigation",
items: [{
text: "Home",
href: "#",
current: true
}, {
text: "Support",
href: "#"
}, {
text: "Features",
href: "#"
}, {
text: "Pricing",
href: "#"
}, {
text: "Contact us",
href: "#"
}]
}) }}
You can use HTML or, if you are using Nunjucks or the GOV.UK Prototype Kit, you can use the Nunjucks macro.
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.
Array |
Required. An array of navigation links. See items.
|
string |
A visually-hidden label to describe the navigation (default is ‘Menu’). |
string |
Classes to add to the primary navigation container. |
object |
HTML attributes (for example data attributes) to add to the navigation container. |
Options for items
string |
Required. Text of the navigation link.
|
string |
Required. The value of the navigation link’s href attribute.
|
boolean |
Indicate that the item is the current page. |
string |
Classes to add to the navigation item. |
Research on this component
This component is based on the Primary navigation component originally developed as part of the Ministry of Justice Design System.
It also follows the design of the GOV.UK One Login service header.