Header
<header class="asp-header">
<div class="asp-header__relative">
<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/113/img/crest-only.png" srcset="https://cdn.policedigital.services/frontend/113/img/crest-only.png 1x, https://cdn.policedigital.services/frontend/113/img/crest-only-2x.png 2x" height="50" width="40" alt="">
<span class="asp-header__app-name asp-header__app-name--separator">Service name</span>
</a>
</div>
<div class="asp-header__bottom">
<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__content--menu" data-toggle-hide-elements=".asp-header__content--search,.asp-header__content--account" style="display:none">Menu</button>
</div>
<div class="asp-header__content asp-header__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>
</div>
<button class="asp-header__button asp-header__button--middle asp-header__button--search asp-js-toggle-button" type="button" data-toggle-element=".asp-header__content--search" data-toggle-hide-elements=".asp-header__content--menu,.asp-header__content--account" style="display:none"><span class="sr-only">Search</span></button>
<div class="asp-header__content asp-header__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__content--account" data-toggle-hide-elements=".asp-header__content--menu,.asp-header__content--search" style="display:none"><span class="sr-only">Account</span></button>
<div class="asp-header__content asp-header__content--account">
<ul class="asp-list--plain asp-header__list">
<li class="asp-header__item asp-header__item--account">
<span class="asp-header__truncate">
Signed in as Christopher King (1234)
</span>
</li>
<li class="asp-header__item asp-header__item--account"><a class="asp-link--plain asp-header__link" href="#">Logout</a></li>
</ul>
</div>
</div>
</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 | Description |
---|---|---|
env | string or false (boolean) | Default values are "staging", "local", "production" false (boolean) or null. |
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 or false (boolean) | icon. | An array of icon information. At least several parameters are required. See
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 |
---|---|---|
src | string or false (boolean) |
default which will display only the crest.
|
Required.
Images urls can be added. Default values are
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) | The text that displays in the image alt. Default values are false (boolean) or null (returns a blank alt). If 'title' is provided or if no other parameters within icon information are set, this 'alt' parameter will be ignored. |
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 |
---|---|---|
env | string or false (boolean) | Default values are "staging", "local", "production" false (boolean) or null. |
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 or false (boolean) | icon. | An array of icon information. At least several parameters are required. See
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 |
---|---|---|
src | string or false (boolean) |
default which will display only the crest.
|
Required.
Images urls can be added. Default values are
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) | The text that displays in the image alt. Default values are false (boolean) or null (returns a blank alt). If 'title' is provided or if no other parameters within icon information are set, this 'alt' parameter will be ignored. |
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