Navigation
-
Header
Use the header to show users they are on an NHS service and help them get started in finding what they need.
<header class="nhsuk-header" role="banner">
<div class="nhsuk-width-container nhsuk-header__container">
<div class="nhsuk-header__logo"><a class="nhsuk-header__link" href="/" aria-label="NHS homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16" height="40" width="100">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
</a>
</div>
<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__menu">
<button class="nhsuk-header__menu-toggle" id="toggle-menu" aria-controls="header-navigation" aria-expanded="false">Menu</button>
</div>
<div class="nhsuk-header__search">
<button class="nhsuk-header__search-toggle" id="toggle-search" aria-controls="search" aria-label="Open search">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="https://www.nhs.uk/search/" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="q" type="search" placeholder="Search" autocomplete="off">
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<button class="nhsuk-search__close" id="close-search">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close search</span>
</button>
</form>
</div>
</div>
</div>
</div>
<nav class="nhsuk-header__navigation" id="header-navigation" role="navigation" aria-label="Primary navigation" aria-labelledby="label-navigation">
<div class="nhsuk-width-container">
<p class="nhsuk-header__navigation-title"><span id="label-navigation">Menu</span>
<button class="nhsuk-header__navigation-close" id="close-menu">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close menu</span>
</button>
</p>
<ul class="nhsuk-header__navigation-list">
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--for-mobile">
<a class="nhsuk-header__navigation-link" href="/">
Home
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/conditions">
Health A-Z
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/live-well/">
Live Well
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/mental-health/">
Mental health
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/conditions/social-care-and-support/">
Care and support
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/pregnancy/">
Pregnancy
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/nhs-services/">
NHS services
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
</ul>
</div>
</nav>
</header>
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.
Name | Type | Required | Description |
---|---|---|---|
Name showNav | Type boolean | Required true | Description Set to `true` to show the navigation links in the header. |
Name showSearch | Type boolean | Required true | Description Set to `true` to show the site search input form. |
Name homeHref | Type string | Required No | Description The `href` of the link for the logo and mobile home link in the navigation links. Defaults to "/" |
Name ariaLabel | Type string | Required No | Description Aria label for the logo href. Defaults to "NHS homepage". |
Name organisation | Type object | Required false | Description Settings for header with organisational logo. |
Name organisation{}.name | Type string | Required false | Description Organisation name value. |
Name organisation{}.descriptor | Type string | Required false | Description Organisation descriptor. |
Name organisation{}.logoURL | Type string | Required true | Description Organisation logo if using a static asset, such as PNG, is preferred. |
Name primaryLinks | Type array | Required false | Description Array of navigation links for use in the header. |
Name primaryLinks[].url | Type string | Required true | Description The href of a navigation item in the header. |
Name primaryLinks[].label | Type string | Required false | Description The label of a navigation item in the header. |
Name transactional | Type string | Required No | Description Set to `true` if this is a transactional header (with smaller logo). |
Name transactionalService | Type object | Required false | Description Settings for transactional service header. |
Name transactionalService{}.name | Type string | Required false | Description Transactional service name value. |
Name transactionalService{}.href | Type string | Required false | Description The href of the transactional header name. |
Name transactionalService{}.longName | Type boolean | Required false | Description Set this to `true` if the transactional service name is longer than 22 characters. |
Name searchAction | Type string | Required No | Description Custom search action endpoint. |
Name searchInputName | Type string | Required No | Description The name for the search field. Defaults to "q" |
Name classes | Type string | Required false | Description Classes to add to the header container. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the header container. |
{% from 'header/macro.njk' import header %}
{{ header({
"showNav": "true",
"showSearch": "true",
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
"label" : "Health A-Z"
},
{
'url' : 'https://www.nhs.uk/live-well/',
'label' : 'Live Well'
},
{
'url' : 'https://www.nhs.uk/mental-health/',
'label' : 'Mental health'
},
{
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
'label' : 'Care and support'
},
{
'url' : 'https://www.nhs.uk/pregnancy/',
'label' : 'Pregnancy'
},
{
'url' : 'https://www.nhs.uk/nhs-services/',
'label' : 'NHS services'
}
]
})
}}
We have 3 versions of the header for services on the NHS website (nhs.uk):
- the default header
- the service header
- the transactional header
We also have an organisational header for other NHS organisations.
When to use the header
Use the NHS default, service or transactional header at the top of every page if your service is on the nhs.uk domain.
Use the organisational header if your service is on another domain.
When not to use the header
Do not use 1 of the nhs.uk headers if your service is on another domain.
How to use
Default header
Use the default header on the NHS website.
<header class="nhsuk-header" role="banner">
<div class="nhsuk-width-container nhsuk-header__container">
<div class="nhsuk-header__logo"><a class="nhsuk-header__link" href="/" aria-label="NHS homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16" height="40" width="100">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
</a>
</div>
<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__menu">
<button class="nhsuk-header__menu-toggle" id="toggle-menu" aria-controls="header-navigation" aria-expanded="false">Menu</button>
</div>
<div class="nhsuk-header__search">
<button class="nhsuk-header__search-toggle" id="toggle-search" aria-controls="search" aria-label="Open search">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="https://www.nhs.uk/search/" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="q" type="search" placeholder="Search" autocomplete="off">
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<button class="nhsuk-search__close" id="close-search">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close search</span>
</button>
</form>
</div>
</div>
</div>
</div>
<nav class="nhsuk-header__navigation" id="header-navigation" role="navigation" aria-label="Primary navigation" aria-labelledby="label-navigation">
<div class="nhsuk-width-container">
<p class="nhsuk-header__navigation-title"><span id="label-navigation">Menu</span>
<button class="nhsuk-header__navigation-close" id="close-menu">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close menu</span>
</button>
</p>
<ul class="nhsuk-header__navigation-list">
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--for-mobile">
<a class="nhsuk-header__navigation-link" href="/">
Home
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/conditions">
Health A-Z
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/live-well/">
Live Well
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/mental-health/">
Mental health
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/conditions/social-care-and-support/">
Care and support
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/pregnancy/">
Pregnancy
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="https://www.nhs.uk/nhs-services/">
NHS services
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
</ul>
</div>
</nav>
</header>
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.
Name | Type | Required | Description |
---|---|---|---|
Name showNav | Type boolean | Required true | Description Set to `true` to show the navigation links in the header. |
Name showSearch | Type boolean | Required true | Description Set to `true` to show the site search input form. |
Name homeHref | Type string | Required No | Description The `href` of the link for the logo and mobile home link in the navigation links. Defaults to "/" |
Name ariaLabel | Type string | Required No | Description Aria label for the logo href. Defaults to "NHS homepage". |
Name organisation | Type object | Required false | Description Settings for header with organisational logo. |
Name organisation{}.name | Type string | Required false | Description Organisation name value. |
Name organisation{}.descriptor | Type string | Required false | Description Organisation descriptor. |
Name organisation{}.logoURL | Type string | Required true | Description Organisation logo if using a static asset, such as PNG, is preferred. |
Name primaryLinks | Type array | Required false | Description Array of navigation links for use in the header. |
Name primaryLinks[].url | Type string | Required true | Description The href of a navigation item in the header. |
Name primaryLinks[].label | Type string | Required false | Description The label of a navigation item in the header. |
Name transactional | Type string | Required No | Description Set to `true` if this is a transactional header (with smaller logo). |
Name transactionalService | Type object | Required false | Description Settings for transactional service header. |
Name transactionalService{}.name | Type string | Required false | Description Transactional service name value. |
Name transactionalService{}.href | Type string | Required false | Description The href of the transactional header name. |
Name transactionalService{}.longName | Type boolean | Required false | Description Set this to `true` if the transactional service name is longer than 22 characters. |
Name searchAction | Type string | Required No | Description Custom search action endpoint. |
Name searchInputName | Type string | Required No | Description The name for the search field. Defaults to "q" |
Name classes | Type string | Required false | Description Classes to add to the header container. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the header container. |
{% from 'header/macro.njk' import header %}
{{ header({
"showNav": "true",
"showSearch": "true",
"primaryLinks": [
{
"url" : "https://www.nhs.uk/conditions",
"label" : "Health A-Z"
},
{
'url' : 'https://www.nhs.uk/live-well/',
'label' : 'Live Well'
},
{
'url' : 'https://www.nhs.uk/mental-health/',
'label' : 'Mental health'
},
{
'url' : 'https://www.nhs.uk/conditions/social-care-and-support/',
'label' : 'Care and support'
},
{
'url' : 'https://www.nhs.uk/pregnancy/',
'label' : 'Pregnancy'
},
{
'url' : 'https://www.nhs.uk/nhs-services/',
'label' : 'NHS services'
}
]
})
}}
Service header
Use the service header if your service is on the NHS website.
<header class="nhsuk-header" role="banner">
<div class="nhsuk-width-container nhsuk-header__container">
<div class="nhsuk-header__logo"><a class="nhsuk-header__link nhsuk-header__link--service " href="/" aria-label="NHS homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16" height="40" width="100">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
<span class="nhsuk-header__service-name">
Digital service manual
</span>
</a>
</div>
<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__menu">
<button class="nhsuk-header__menu-toggle" id="toggle-menu" aria-controls="header-navigation" aria-expanded="false">Menu</button>
</div>
<div class="nhsuk-header__search">
<button class="nhsuk-header__search-toggle" id="toggle-search" aria-controls="search" aria-label="Open search">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="https://www.nhs.uk/search/" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="q" type="search" placeholder="Search" autocomplete="off">
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<button class="nhsuk-search__close" id="close-search">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close search</span>
</button>
</form>
</div>
</div>
</div>
</div>
<nav class="nhsuk-header__navigation" id="header-navigation" role="navigation" aria-label="Primary navigation" aria-labelledby="label-navigation">
<div class="nhsuk-width-container">
<p class="nhsuk-header__navigation-title"><span id="label-navigation">Menu</span>
<button class="nhsuk-header__navigation-close" id="close-menu">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close menu</span>
</button>
</p>
<ul class="nhsuk-header__navigation-list">
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--for-mobile">
<a class="nhsuk-header__navigation-link" href="/">
Home
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
NHS service standard
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Design system
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Content style guide
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Accessibility
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Community and contribution
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
</ul>
</div>
</nav>
</header>
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.
Name | Type | Required | Description |
---|---|---|---|
Name showNav | Type boolean | Required true | Description Set to `true` to show the navigation links in the header. |
Name showSearch | Type boolean | Required true | Description Set to `true` to show the site search input form. |
Name homeHref | Type string | Required No | Description The `href` of the link for the logo and mobile home link in the navigation links. Defaults to "/" |
Name ariaLabel | Type string | Required No | Description Aria label for the logo href. Defaults to "NHS homepage". |
Name organisation | Type object | Required false | Description Settings for header with organisational logo. |
Name organisation{}.name | Type string | Required false | Description Organisation name value. |
Name organisation{}.descriptor | Type string | Required false | Description Organisation descriptor. |
Name organisation{}.logoURL | Type string | Required true | Description Organisation logo if using a static asset, such as PNG, is preferred. |
Name primaryLinks | Type array | Required false | Description Array of navigation links for use in the header. |
Name primaryLinks[].url | Type string | Required true | Description The href of a navigation item in the header. |
Name primaryLinks[].label | Type string | Required false | Description The label of a navigation item in the header. |
Name transactional | Type string | Required No | Description Set to `true` if this is a transactional header (with smaller logo). |
Name transactionalService | Type object | Required false | Description Settings for transactional service header. |
Name transactionalService{}.name | Type string | Required false | Description Transactional service name value. |
Name transactionalService{}.href | Type string | Required false | Description The href of the transactional header name. |
Name transactionalService{}.longName | Type boolean | Required false | Description Set this to `true` if the transactional service name is longer than 22 characters. |
Name searchAction | Type string | Required No | Description Custom search action endpoint. |
Name searchInputName | Type string | Required No | Description The name for the search field. Defaults to "q" |
Name classes | Type string | Required false | Description Classes to add to the header container. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the header container. |
{% from 'header/macro.njk' import header %}
{{ header({
"service": {
"name": "Digital service manual"
},
"showNav": "true",
"showSearch": "true",
"primaryLinks": [
{
"url" : "#",
"label" : "NHS service standard"
},
{
'url' : '#',
'label' : 'Design system'
},
{
'url' : '#',
'label' : 'Content style guide'
},
{
'url' : '#',
'label' : 'Accessibility'
},
{
'url' : '#',
'label' : 'Community and contribution'
}
]
})
}}
Transactional header
Use the transactional header for transactional journeys on the NHS website. Include the service name to help users understand which service they are using.
We have found that the full header is too distracting to be used in transactional services.
<header class="nhsuk-header nhsuk-header--transactional" role="banner">
<div class="nhsuk-width-container nhsuk-header__container">
<div class="nhsuk-header__logo nhsuk-header__logo--only"><a class="nhsuk-header__link" href="/" aria-label="NHS homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16" height="40" width="100">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
</a>
</div>
<div class="nhsuk-header__transactional-service-name">
<a class="nhsuk-header__transactional-service-name--link" href="https://www.nhs.uk/nhs-services/gps/how-to-register-with-a-gp-surgery/">Register with a GP</a>
</div>
</div>
</header>
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.
Name | Type | Required | Description |
---|---|---|---|
Name showNav | Type boolean | Required true | Description Set to `true` to show the navigation links in the header. |
Name showSearch | Type boolean | Required true | Description Set to `true` to show the site search input form. |
Name homeHref | Type string | Required No | Description The `href` of the link for the logo and mobile home link in the navigation links. Defaults to "/" |
Name ariaLabel | Type string | Required No | Description Aria label for the logo href. Defaults to "NHS homepage". |
Name organisation | Type object | Required false | Description Settings for header with organisational logo. |
Name organisation{}.name | Type string | Required false | Description Organisation name value. |
Name organisation{}.descriptor | Type string | Required false | Description Organisation descriptor. |
Name organisation{}.logoURL | Type string | Required true | Description Organisation logo if using a static asset, such as PNG, is preferred. |
Name primaryLinks | Type array | Required false | Description Array of navigation links for use in the header. |
Name primaryLinks[].url | Type string | Required true | Description The href of a navigation item in the header. |
Name primaryLinks[].label | Type string | Required false | Description The label of a navigation item in the header. |
Name transactional | Type string | Required No | Description Set to `true` if this is a transactional header (with smaller logo). |
Name transactionalService | Type object | Required false | Description Settings for transactional service header. |
Name transactionalService{}.name | Type string | Required false | Description Transactional service name value. |
Name transactionalService{}.href | Type string | Required false | Description The href of the transactional header name. |
Name transactionalService{}.longName | Type boolean | Required false | Description Set this to `true` if the transactional service name is longer than 22 characters. |
Name searchAction | Type string | Required No | Description Custom search action endpoint. |
Name searchInputName | Type string | Required No | Description The name for the search field. Defaults to "q" |
Name classes | Type string | Required false | Description Classes to add to the header container. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the header container. |
{% from 'header/macro.njk' import header %}
{{ header({
"transactionalService": {
"name": "Register with a GP",
"href": "https://www.nhs.uk/nhs-services/gps/how-to-register-with-a-gp-surgery/"
},
"showNav": "false",
"showSearch": "false"
})
}}
Organisational header
Use the organisational header if your NHS organisation or service is not part of the NHS website, for example, for an NHS clinical commissioning group or an NHS trust.
You must have a Frutiger font licence to use an organisational logo. Our guidance on typography explains how to get hold of the webfont. Read more about creating NHS organisational logos in the NHS England identity guidelines.
<header class="nhsuk-header nhsuk-header--organisation" role="banner">
<div class="nhsuk-width-container nhsuk-header__container">
<div class="nhsuk-header__logo">
<a class="nhsuk-header__link" href="/" aria-label="Anytown Anyplace Anywhere NHS Foundation Trust homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16" height="40" width="100">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
<span class="nhsuk-organisation-name">Anytown Anyplace <span class="nhsuk-organisation-name-split">Anywhere</span></span>
<span class="nhsuk-organisation-descriptor">NHS Foundation Trust</span>
</a>
</div>
<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__menu">
<button class="nhsuk-header__menu-toggle" id="toggle-menu" aria-controls="header-navigation" aria-expanded="false">Menu</button>
</div>
<div class="nhsuk-header__search">
<button class="nhsuk-header__search-toggle" id="toggle-search" aria-controls="search" aria-label="Open search">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="https://www.nhs.uk/search/" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="q" type="search" placeholder="Search" autocomplete="off">
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<button class="nhsuk-search__close" id="close-search">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close search</span>
</button>
</form>
</div>
</div>
</div>
</div>
<nav class="nhsuk-header__navigation" id="header-navigation" role="navigation" aria-label="Primary navigation" aria-labelledby="label-navigation">
<div class="nhsuk-width-container">
<p class="nhsuk-header__navigation-title"><span id="label-navigation">Menu</span>
<button class="nhsuk-header__navigation-close" id="close-menu">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close menu</span>
</button>
</p>
<ul class="nhsuk-header__navigation-list">
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--for-mobile">
<a class="nhsuk-header__navigation-link" href="/">
Home
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Your hospital visit
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Wards and departments
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Conditions and treatments
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Our people
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Our research
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
</ul>
</div>
</nav>
</header>
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.
Name | Type | Required | Description |
---|---|---|---|
Name showNav | Type boolean | Required true | Description Set to `true` to show the navigation links in the header. |
Name showSearch | Type boolean | Required true | Description Set to `true` to show the site search input form. |
Name homeHref | Type string | Required No | Description The `href` of the link for the logo and mobile home link in the navigation links. Defaults to "/" |
Name ariaLabel | Type string | Required No | Description Aria label for the logo href. Defaults to "NHS homepage". |
Name organisation | Type object | Required false | Description Settings for header with organisational logo. |
Name organisation{}.name | Type string | Required false | Description Organisation name value. |
Name organisation{}.descriptor | Type string | Required false | Description Organisation descriptor. |
Name organisation{}.logoURL | Type string | Required true | Description Organisation logo if using a static asset, such as PNG, is preferred. |
Name primaryLinks | Type array | Required false | Description Array of navigation links for use in the header. |
Name primaryLinks[].url | Type string | Required true | Description The href of a navigation item in the header. |
Name primaryLinks[].label | Type string | Required false | Description The label of a navigation item in the header. |
Name transactional | Type string | Required No | Description Set to `true` if this is a transactional header (with smaller logo). |
Name transactionalService | Type object | Required false | Description Settings for transactional service header. |
Name transactionalService{}.name | Type string | Required false | Description Transactional service name value. |
Name transactionalService{}.href | Type string | Required false | Description The href of the transactional header name. |
Name transactionalService{}.longName | Type boolean | Required false | Description Set this to `true` if the transactional service name is longer than 22 characters. |
Name searchAction | Type string | Required No | Description Custom search action endpoint. |
Name searchInputName | Type string | Required No | Description The name for the search field. Defaults to "q" |
Name classes | Type string | Required false | Description Classes to add to the header container. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the header container. |
{% from 'header/macro.njk' import header %}
{{ header({
"showNav": "true",
"showSearch": "true",
"organisation": {
"name": "Anytown Anyplace",
"split": "Anywhere",
"descriptor": "NHS Foundation Trust"
},
"primaryLinks": [
{
"url" : "#",
"label" : "Your hospital visit"
},
{
'url' : '#',
'label' : 'Wards and departments'
},
{
'url' : '#',
'label' : 'Conditions and treatments'
},
{
'url' : '#',
'label' : 'Our people'
},
{
'url' : '#',
'label' : 'Our research'
}
]
})
}}
White variant
<header class="nhsuk-header nhsuk-header--organisation nhsuk-header--white" role="banner">
<div class="nhsuk-width-container nhsuk-header__container">
<div class="nhsuk-header__logo">
<a class="nhsuk-header__link" href="/" aria-label="Anytown Anyplace Anywhere NHS Foundation Trust homepage">
<svg class="nhsuk-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 16" height="40" width="100">
<path class="nhsuk-logo__background" fill="#005eb8" d="M0 0h40v16H0z"></path>
<path class="nhsuk-logo__text" fill="#fff" d="M3.9 1.5h4.4l2.6 9h.1l1.8-9h3.3l-2.8 13H9l-2.7-9h-.1l-1.8 9H1.1M17.3 1.5h3.6l-1 4.9h4L25 1.5h3.5l-2.7 13h-3.5l1.1-5.6h-4.1l-1.2 5.6h-3.4M37.7 4.4c-.7-.3-1.6-.6-2.9-.6-1.4 0-2.5.2-2.5 1.3 0 1.8 5.1 1.2 5.1 5.1 0 3.6-3.3 4.5-6.4 4.5-1.3 0-2.9-.3-4-.7l.8-2.7c.7.4 2.1.7 3.2.7s2.8-.2 2.8-1.5c0-2.1-5.1-1.3-5.1-5 0-3.4 2.9-4.4 5.8-4.4 1.6 0 3.1.2 4 .6"></path>
</svg>
<span class="nhsuk-organisation-name">Anytown Anyplace <span class="nhsuk-organisation-name-split">Anywhere</span></span>
<span class="nhsuk-organisation-descriptor">NHS Foundation Trust</span>
</a>
</div>
<div class="nhsuk-header__content" id="content-header">
<div class="nhsuk-header__menu">
<button class="nhsuk-header__menu-toggle" id="toggle-menu" aria-controls="header-navigation" aria-expanded="false">Menu</button>
</div>
<div class="nhsuk-header__search">
<button class="nhsuk-header__search-toggle" id="toggle-search" aria-controls="search" aria-label="Open search">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<div class="nhsuk-header__search-wrap" id="wrap-search">
<form class="nhsuk-header__search-form" id="search" action="https://www.nhs.uk/search/" method="get" role="search">
<label class="nhsuk-u-visually-hidden" for="search-field">Search the NHS website</label>
<input class="nhsuk-search__input" id="search-field" name="q" type="search" placeholder="Search" autocomplete="off">
<button class="nhsuk-search__submit" type="submit">
<svg class="nhsuk-icon nhsuk-icon__search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M19.71 18.29l-4.11-4.1a7 7 0 1 0-1.41 1.41l4.1 4.11a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42zM5 10a5 5 0 1 1 5 5 5 5 0 0 1-5-5z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Search</span>
</button>
<button class="nhsuk-search__close" id="close-search">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close search</span>
</button>
</form>
</div>
</div>
</div>
</div>
<nav class="nhsuk-header__navigation" id="header-navigation" role="navigation" aria-label="Primary navigation" aria-labelledby="label-navigation">
<div class="nhsuk-width-container">
<p class="nhsuk-header__navigation-title"><span id="label-navigation">Menu</span>
<button class="nhsuk-header__navigation-close" id="close-menu">
<svg class="nhsuk-icon nhsuk-icon__close" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" width="27" height="27">
<path d="M13.41 12l5.3-5.29a1 1 0 1 0-1.42-1.42L12 10.59l-5.29-5.3a1 1 0 0 0-1.42 1.42l5.3 5.29-5.3 5.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0l5.29-5.3 5.29 5.3a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42z"></path>
</svg>
<span class="nhsuk-u-visually-hidden">Close menu</span>
</button>
</p>
<ul class="nhsuk-header__navigation-list">
<li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--for-mobile">
<a class="nhsuk-header__navigation-link" href="/">
Home
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Your hospital visit
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Wards and departments
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Conditions and treatments
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Our people
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
<li class="nhsuk-header__navigation-item">
<a class="nhsuk-header__navigation-link" href="#">
Our research
<svg class="nhsuk-icon nhsuk-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
</svg>
</a>
</li>
</ul>
</div>
</nav>
</header>
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.
Name | Type | Required | Description |
---|---|---|---|
Name showNav | Type boolean | Required true | Description Set to `true` to show the navigation links in the header. |
Name showSearch | Type boolean | Required true | Description Set to `true` to show the site search input form. |
Name homeHref | Type string | Required No | Description The `href` of the link for the logo and mobile home link in the navigation links. Defaults to "/" |
Name ariaLabel | Type string | Required No | Description Aria label for the logo href. Defaults to "NHS homepage". |
Name organisation | Type object | Required false | Description Settings for header with organisational logo. |
Name organisation{}.name | Type string | Required false | Description Organisation name value. |
Name organisation{}.descriptor | Type string | Required false | Description Organisation descriptor. |
Name organisation{}.logoURL | Type string | Required true | Description Organisation logo if using a static asset, such as PNG, is preferred. |
Name primaryLinks | Type array | Required false | Description Array of navigation links for use in the header. |
Name primaryLinks[].url | Type string | Required true | Description The href of a navigation item in the header. |
Name primaryLinks[].label | Type string | Required false | Description The label of a navigation item in the header. |
Name transactional | Type string | Required No | Description Set to `true` if this is a transactional header (with smaller logo). |
Name transactionalService | Type object | Required false | Description Settings for transactional service header. |
Name transactionalService{}.name | Type string | Required false | Description Transactional service name value. |
Name transactionalService{}.href | Type string | Required false | Description The href of the transactional header name. |
Name transactionalService{}.longName | Type boolean | Required false | Description Set this to `true` if the transactional service name is longer than 22 characters. |
Name searchAction | Type string | Required No | Description Custom search action endpoint. |
Name searchInputName | Type string | Required No | Description The name for the search field. Defaults to "q" |
Name classes | Type string | Required false | Description Classes to add to the header container. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the header container. |
{% from 'header/macro.njk' import header %}
{{ header({
"showNav": "true",
"showSearch": "true",
"classes": "nhsuk-header--white",
"organisation": {
"name": "Anytown Anyplace",
"split": "Anywhere",
"descriptor": "NHS Foundation Trust"
},
"primaryLinks": [
{
"url" : "#",
"label" : "Your hospital visit"
},
{
'url' : '#',
'label' : 'Wards and departments'
},
{
'url' : '#',
'label' : 'Conditions and treatments'
},
{
'url' : '#',
'label' : 'Our people'
},
{
'url' : '#',
'label' : 'Our research'
}
]
})
}}
The organisational logo is an SVG and you can change the organisation name and descriptor in the code. Longer organisation names should be split onto 2 lines.
You can also use a static asset, such as a PNG file.
<a class="nhsuk-header__link" href="/" aria-label="Anyplace Anytown Anywhere NHS Foundation Trust homepage">
<img class="nhsuk-org-logo" src="/path-to-assets/logo.png" alt="">
</a>
Have you tested this component?
If so, please share your research findings and let us know how it has worked for you. This will help us improve it for everyone.
Before you start, you will need a GitHub account. It's an open forum where we collect feedback.
If you have any questions, you can message us on Slack. You will need a Slack account if you do not have one. Or you can contact us by email.
Updated: August 2020