Alert

<div class="alert alert--success">
  <h1 class="alert__title">Alert title</h1>
  <div class="alert__content">
    <p>Alert content (html) with a <a href="#">link</a></p>
          <p>With additional line. modifier: success</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
modifier string or false (boolean) Default values are 'success', 'danger', 'warning', 'hidden', 'code', 'notice', false (boolean) or null.
title string or false (boolean) The alert component title. Note; The title will be blank if the modifer is 'warning', 'code' or 'notice'. Default values are false (boolean) or null.
content array Required. The text that displays in the alert component content. See content.

Options for content

Name Type Description
html string Required. HTML for the alert component content. If 'html' is provided, the 'text' parameter will be ignored.
text string Required. Text for the alert component content. If 'html' is provided, the 'text' parameter will be ignored.
{% from "alert/macro.njk" import aspAlert %}

{{ aspAlert({
modifier: "success",
title: "Alert title",
content: {
html: '<p>Alert content (html) with a <a href="#">link</a></p>
<p>With additional line. modifier: success</p>' }
}) }}

<div class="alert alert--warning">
  <div class="alert__content">
    <p>Alert content (text) without a title. modifier: warning</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
modifier string or false (boolean) Default values are 'success', 'danger', 'warning', 'hidden', 'code', 'notice', false (boolean) or null.
title string or false (boolean) The alert component title. Note; The title will be blank if the modifer is 'warning', 'code' or 'notice'. Default values are false (boolean) or null.
content array Required. The text that displays in the alert component content. See content.

Options for content

Name Type Description
html string Required. HTML for the alert component content. If 'html' is provided, the 'text' parameter will be ignored.
text string Required. Text for the alert component content. If 'html' is provided, the 'text' parameter will be ignored.
{% from "alert/macro.njk" import aspAlert %}

{{ aspAlert({
modifier: "warning",
content: {
text: "Alert content (text) without a title. modifier: warning"
}
}) }}

<div class="alert alert--danger">
  <div class="alert__content">
    <p>Alert content (text) without a title. modifier: danger</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
modifier string or false (boolean) Default values are 'success', 'danger', 'warning', 'hidden', 'code', 'notice', false (boolean) or null.
title string or false (boolean) The alert component title. Note; The title will be blank if the modifer is 'warning', 'code' or 'notice'. Default values are false (boolean) or null.
content array Required. The text that displays in the alert component content. See content.

Options for content

Name Type Description
html string Required. HTML for the alert component content. If 'html' is provided, the 'text' parameter will be ignored.
text string Required. Text for the alert component content. If 'html' is provided, the 'text' parameter will be ignored.
{% from "alert/macro.njk" import aspAlert %}

{{ aspAlert({
modifier: "danger",
content: {
text: "Alert content (text) without a title. modifier: danger"
}
}) }}

Alias

A (left aligned) alert is now a notification component.

Status of development

The below criteria all need to be met for a component to be considered as fully developed for use within the ASP Digital Design System.

Development criteria Status
WCAG 2.2 compliant Not started
WCAG 2.1 compliant Failing
HTML / Nunjucks version Completed
Figma version Not started
M365 versions Not started
Documentation In progress

Published 3 May 2024
Last updated 13 September 2024