Service navigation Nunjucks macro options

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

Also see the guidance on the Service navigation component page, which shows these options in use within each example.

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

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.
collapseNavigationOnMobile boolean Whether the navigation should be collapsed inside a menu on mobile. Defaults to true if there is more than one navigation item.
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 macro options for navigation.
slots object Specified points for injecting custom HTML into the service header. See macro options for 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.
end object Options for injecting HTML at the end of the service header container. See macro options for slots end.
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.
Options for slots end object
Name Type Description
html string HTML injected at the end of the service header container.
align string By default, the end slot renders below the navigation items. Use inline to render it on the same line as the navigation items when space is available.