Notification banner
Use a notification banner to tell the user about something they need to know about, but that’s not directly related to the page content.
Telling the user about a problem that affects the whole service
Use a purple notification banner if the user needs to know about a problem with the service as a whole.
<div
class="govuk-notification-banner"
role="region"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner"
>
<div class="govuk-notification-banner__header">
<h2
class="govuk-notification-banner__title"
id="govuk-notification-banner-title"
>
Important
</h2>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-notification-banner__heading">
There may be a delay in processing your application because of the
coronavirus outbreak.
</p>
</div>
</div>
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 |
---|---|---|
text | string | Required. The text that displays in the notification banner. You can use any string with this option. If you set |
html | string | Required. The HTML to use within the notification banner. You can use any string with this option. If you set |
caller | nunjucks-block | Not strictly a parameter but Nunjucks code convention. Using a |
titleText | string | The title text that displays in the notification banner. You can use any string with this option. Use this option to set text that does not contain HTML. The available default values are 'Important', 'Success', and null:
|
titleHtml | string | The title HTML to use within the notification banner. You can use any string with this option. Use this option to set text that contains HTML. If you set |
titleHeadingLevel | string | Sets heading level for the title only. You can only use values between |
type | string | The type of notification to render. You can use only |
role | string | Overrides the value of the |
titleId | string | The |
disableAutoFocus | boolean | If you set |
classes | string | The classes that you want to add to the notification banner. |
attributes | object | The HTML attributes that you want to add to the notification banner, for example, data attributes. |
{% from "moduk/components/notification-banner/macro.njk" import modukNotificationBanner -%}
{{ modukNotificationBanner({
text: 'There may be a delay in processing your application because of the coronavirus outbreak.'
}) -}}
Telling the user about something that’s happening elsewhere
Use a purple notification banner if the user needs to know about something that’s happening elsewhere in the service.
<div
class="govuk-notification-banner"
role="region"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner"
>
<div class="govuk-notification-banner__header">
<h2
class="govuk-notification-banner__title"
id="govuk-notification-banner-title"
>
Important
</h2>
</div>
<div class="govuk-notification-banner__content">
<p class="govuk-notification-banner__heading">
You have 7 days left to send your application.
<a class="govuk-notification-banner__link" href="#">View application</a>.
</p>
</div>
</div>
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 |
---|---|---|
text | string | Required. The text that displays in the notification banner. You can use any string with this option. If you set |
html | string | Required. The HTML to use within the notification banner. You can use any string with this option. If you set |
caller | nunjucks-block | Not strictly a parameter but Nunjucks code convention. Using a |
titleText | string | The title text that displays in the notification banner. You can use any string with this option. Use this option to set text that does not contain HTML. The available default values are 'Important', 'Success', and null:
|
titleHtml | string | The title HTML to use within the notification banner. You can use any string with this option. Use this option to set text that contains HTML. If you set |
titleHeadingLevel | string | Sets heading level for the title only. You can only use values between |
type | string | The type of notification to render. You can use only |
role | string | Overrides the value of the |
titleId | string | The |
disableAutoFocus | boolean | If you set |
classes | string | The classes that you want to add to the notification banner. |
attributes | object | The HTML attributes that you want to add to the notification banner, for example, data attributes. |
{% from "moduk/components/notification-banner/macro.njk" import modukNotificationBanner -%}
{% set html %}
<p class="govuk-notification-banner__heading">
You have 7 days left to send your application.
<a class="govuk-notification-banner__link" href="#">View application</a>.
</p>
{% endset -%}
{{ modukNotificationBanner({
html: html
}) -}}
Reacting to something the user has done
Use the green version of the notification banner to confirm that something the user is expecting to happen has happened.
<div
class="govuk-notification-banner govuk-notification-banner--success"
role="alert"
aria-labelledby="govuk-notification-banner-title"
data-module="govuk-notification-banner"
>
<div class="govuk-notification-banner__header">
<h2
class="govuk-notification-banner__title"
id="govuk-notification-banner-title"
>
Success
</h2>
</div>
<div class="govuk-notification-banner__content">
<h3 class="govuk-notification-banner__heading">
Training outcome recorded and trainee withdrawn
</h3>
<p class="govuk-body">
Contact
<a class="govuk-notification-banner__link" href="#"
>example@department.gov.uk</a
>
if you think there’s a problem.
</p>
</div>
</div>
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 |
---|---|---|
text | string | Required. The text that displays in the notification banner. You can use any string with this option. If you set |
html | string | Required. The HTML to use within the notification banner. You can use any string with this option. If you set |
caller | nunjucks-block | Not strictly a parameter but Nunjucks code convention. Using a |
titleText | string | The title text that displays in the notification banner. You can use any string with this option. Use this option to set text that does not contain HTML. The available default values are 'Important', 'Success', and null:
|
titleHtml | string | The title HTML to use within the notification banner. You can use any string with this option. Use this option to set text that contains HTML. If you set |
titleHeadingLevel | string | Sets heading level for the title only. You can only use values between |
type | string | The type of notification to render. You can use only |
role | string | Overrides the value of the |
titleId | string | The |
disableAutoFocus | boolean | If you set |
classes | string | The classes that you want to add to the notification banner. |
attributes | object | The HTML attributes that you want to add to the notification banner, for example, data attributes. |
{% from "moduk/components/notification-banner/macro.njk" import modukNotificationBanner -%}
{% set html %}
<h3 class="govuk-notification-banner__heading">
Training outcome recorded and trainee withdrawn
</h3>
<p class="govuk-body">Contact <a class="govuk-notification-banner__link" href="#">example@department.gov.uk</a> if you think there’s a problem.</p>
{% endset -%}
{{ modukNotificationBanner({
html: html,
type: 'success'
}) -}}
See GOV.UK notification banner component guidance for:
- when to use this component
- when not to use it
- how it works
Changes from the GOV.UK version
MOD.UK Design System components are closely based on GOV.UK Design System components.
For this component we’ve changed the font and colours.
Have you tested this component?
Let us know how we could improve this component or share your user research findings.
Email the MOD.UK Design System team at design-system@digital.mod.uk
Need help?
Email the MOD.UK Design System team at design-system@digital.mod.uk if you have questions or feedback.