Header
<header class="asp-header asp-header--border">
<div class="asp-header__container--top">
<div class="asp-container">
<a class="asp-link--plain asp-header__link asp-header__app" href="#">
<img class="asp-header__app-logo" src="https://cdn.policedigital.services/frontend/124/img/asp-crest-with-text.svg" height="50" width="264" alt="Avon and Somerset Police">
</a>
</div>
</div>
<div class="asp-header__container--bottom">
<div class="asp-header__mobile">
<button class="asp-header__button asp-header__button--left asp-header__button--menu asp-js-toggle-button" type="button" data-toggle-element=".asp-header__js-content--menu" data-toggle-hide-elements=".asp-header__js-content--search,.asp-header__js-content--account" style="display:none">Menu</button>
</div>
<nav class="asp-header__content asp-header__content--menu asp-header__js-content--menu">
<ul class="asp-list--plain asp-header__list">
<li class="asp-header__item"><a class="asp-link--plain asp-header__link" href="#">Menu item 1</a></li>
<li class="asp-header__item"><a class="asp-link--plain asp-header__link" href="#">Menu item 2</a></li>
</ul>
</nav>
<button class="asp-header__button asp-header__button--middle asp-header__button--search asp-js-toggle-button" type="button" data-toggle-element=".asp-header__js-content--search" data-toggle-hide-elements=".asp-header__js-content--menu,.asp-header__js-content--account" style="display:none"><span class="sr-only">Search</span></button>
<div class="asp-header__content asp-header__content--top-right asp-header__content--search asp-header__js-content--search">
<form class="form__group--inner form__group--inner-with-button asp-header__search--form">
<label class="form__label sr-only" for="asp-header__search">Search undefined</label>
<input class="form__input" id="asp-header__search" type="text">
<button class="asp-button asp-button--start asp-button--append asp-header__button--search asp-header__button--search-form" type="submit"><span class="sr-only">Search</span></button>
</form>
</div>
<button class="asp-header__button asp-header__button--right asp-header__button--account asp-js-toggle-button" type="button" data-toggle-element=".asp-header__js-content--account" data-toggle-hide-elements=".asp-header__js-content--menu,.asp-header__js-content--search" style="display:none"><span class="sr-only">Account</span></button>
<nav class="asp-header__content asp-header__js-content--account">
<ul class="asp-list--plain asp-header__list asp-header__list--account">
<li class="asp-header__item asp-header__item--truncate">
<span class="asp-header__truncate"><span class="sr-only">Signed in as </span> Christopher King (1234)</span>
</li>
<li class="asp-header__item"><a class="asp-link--plain asp-header__link asp-header__link--account" href="#">Logout</a></li>
</ul>
</nav>
</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 | Description |
---|---|---|
app | object | app. | Required. Object of app information. At least several parameters are required. See
menu | array | menu. | A list of menu links. See
search | array or false (boolean) | search. | If true, search will show. The array below can be built up to customise search settings. At least one paramater is required. See
account | array or false (boolean) | account. | An array of account settings. At least one parameter is required. See
Options for app
Name | Type | Description |
---|---|---|
title | string or false (boolean) | The title of the app. |
href | string | Required. The URL that the image and title will link to. |
icon | array, string or null |
default or null which will display the formation / citizen site logo (crest with text) and crest which will display the image with the only the crest. If default , crest or null, the following parameters will be ignored.
See icon.
|
An array of icon information. At least several parameters are required. Default values are
separator | boolean | If true, a separator between the logo and title will be displayed. Default values are false (boolean), true (boolean) or null. |
Options for icon
Name | Type | Description |
---|---|---|
height | number or false (boolean) | This is the height of the header image. Default value is 50. |
width | number | This is the width of the header image. Required if 'src' is a string. |
alt | string or false (boolean) |
default or if no other parameters within icon information are set, this 'alt' parameter will be ignored.
|
The text that displays in the image alt. Default values are false (boolean) or null (returns a blank alt). If 'title' is provided, the 'icon' is
source | string or false (boolean) |
source parameter will be ignored.
|
The image url. Default values are 'default', false (boolean) or null. Note; 'default', false (boolean) or null will return the default image. To use additional webp or srcset use sources parameters. If sources are correct, this
sources | array or false (boolean) |
jpgpx1 is required with either; jpgpx2 for retina image srcset or webpx1 for a webp picture with srcsets. If all options are present then a picture element will be present with all options available.
See sources.
|
Array of image urls all needed to create the srcsets options within the picture element. Default values are false (boolean) or null. If false (boolean), the following parameters will be ignored.
Options for sources
Name | Type | Description |
---|---|---|
jpgpx1 | string | Required. The url for 1x pixel density for a jpg or jpeg format image. If this is the only source, the image can be a retina image 2:1. |
jpgpx2 | string | The url for 2x pixel density for a jpg or jpeg format image. |
webpx1 | string | The url for 1x pixel density for a webp format image. |
webpx2 | string | The url for 2x pixel density for a webp format image. |
Options for menu
Name | Type | Description |
---|---|---|
href | string | Required. The URL of menu item. |
text | string | Required. The text of menu item. |
Options for search
Name | Type | Description |
---|---|---|
form | array or false (boolean) |
action , id and method .
See form.
|
A list of additional attributes for the form. Common attribute names for form are
label | string of false (boolean) | If present this will |
input | array or false (boolean) |
placeholder and value .
See input.
|
A list of additional attributes for the input. Common attribute names for input are
Options for form
Name | Type | Description |
---|---|---|
name | string | Required. The name of the attribute. |
value | string | The value of the attribute. Note, boolean values must be strings. Default values are false (boolean) or null. |
Options for input
Name | Type | Description |
---|---|---|
name | string | Required. The name of the attribute. |
value | string | The value of the attribute. Note, boolean values must be strings. Default values are false (boolean) or null. |
Options for account
Name | Type | Description |
---|---|---|
name | string | Name of person logged in account. |
logout | string or false (boolean) | The URL of the logout page. |
{% from "components/header/macro.njk" import aspHeader %}
{{ aspHeader({
app: {
title: "Service name",
href: "#",
icon: "default",
separator: true
},
menu: [
{
text: "Menu item 1",
href: "#"
},
{
text: "Menu item 2",
href: "#"
}
],
search: true,
account: {
name: "Christopher King (1234)",
logout: "#"
}
}) }}
Twig 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 | Description |
---|---|---|
app | object | app. | Required. Object of app information. At least several parameters are required. See
menu | array | menu. | A list of menu links. See
search | array or false (boolean) | search. | If true, search will show. The array below can be built up to customise search settings. At least one paramater is required. See
account | array or false (boolean) | account. | An array of account settings. At least one parameter is required. See
Options for app
Name | Type | Description |
---|---|---|
title | string or false (boolean) | The title of the app. |
href | string | Required. The URL that the image and title will link to. |
icon | array, string or null |
default or null which will display the formation / citizen site logo (crest with text) and crest which will display the image with the only the crest. If default , crest or null, the following parameters will be ignored.
See icon.
|
An array of icon information. At least several parameters are required. Default values are
separator | boolean | If true, a separator between the logo and title will be displayed. Default values are false (boolean), true (boolean) or null. |
Options for icon
Name | Type | Description |
---|---|---|
height | number or false (boolean) | This is the height of the header image. Default value is 50. |
width | number | This is the width of the header image. Required if 'src' is a string. |
alt | string or false (boolean) |
default or if no other parameters within icon information are set, this 'alt' parameter will be ignored.
|
The text that displays in the image alt. Default values are false (boolean) or null (returns a blank alt). If 'title' is provided, the 'icon' is
source | string or false (boolean) |
source parameter will be ignored.
|
The image url. Default values are 'default', false (boolean) or null. Note; 'default', false (boolean) or null will return the default image. To use additional webp or srcset use sources parameters. If sources are correct, this
sources | array or false (boolean) |
jpgpx1 is required with either; jpgpx2 for retina image srcset or webpx1 for a webp picture with srcsets. If all options are present then a picture element will be present with all options available.
See sources.
|
Array of image urls all needed to create the srcsets options within the picture element. Default values are false (boolean) or null. If false (boolean), the following parameters will be ignored.
Options for sources
Name | Type | Description |
---|---|---|
jpgpx1 | string | Required. The url for 1x pixel density for a jpg or jpeg format image. If this is the only source, the image can be a retina image 2:1. |
jpgpx2 | string | The url for 2x pixel density for a jpg or jpeg format image. |
webpx1 | string | The url for 1x pixel density for a webp format image. |
webpx2 | string | The url for 2x pixel density for a webp format image. |
Options for menu
Name | Type | Description |
---|---|---|
href | string | Required. The URL of menu item. |
text | string | Required. The text of menu item. |
Options for search
Name | Type | Description |
---|---|---|
form | array or false (boolean) |
action , id and method .
See form.
|
A list of additional attributes for the form. Common attribute names for form are
label | string of false (boolean) | If present this will |
input | array or false (boolean) |
placeholder and value .
See input.
|
A list of additional attributes for the input. Common attribute names for input are
Options for form
Name | Type | Description |
---|---|---|
name | string | Required. The name of the attribute. |
value | string | The value of the attribute. Note, boolean values must be strings. Default values are false (boolean) or null. |
Options for input
Name | Type | Description |
---|---|---|
name | string | Required. The name of the attribute. |
value | string | The value of the attribute. Note, boolean values must be strings. Default values are false (boolean) or null. |
Options for account
Name | Type | Description |
---|---|---|
name | string | Name of person logged in account. |
logout | string or false (boolean) | The URL of the logout page. |
{% from "@asp-frontend/components/header/macro.twig" import aspHeader %}
{{ aspHeader({
app: {
title: "Service name",
href: "#",
icon: "default",
separator: true
},
menu: [
{
text: "Menu item 1",
href: "#"
},
{
text: "Menu item 2",
href: "#"
}
],
search: true,
account: {
name: "Christopher King (1234)",
logout: "#"
}
}) }}
Published 14 April 2025
Last updated 28 April 2025