Skip to content

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 "components/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>' }
}) }}

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
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 "asp-frontend/components/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>' }
}) }}

Name Type Description
HTMLText string Required. HTML text input for text within the component.
Font string Required. This is the font that the text will be shown in. This will likely be Font.'Segoe UI'.
Size number Required. Number input for body text size.
Type string Required. Text input, use either “Green”, “Red” or “Grey” to switch between variations. Can be controlled with a variable.

The amber and red versions of the alert component have been replaced by the notification component.

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 Completed
Documentation In progress

Published 3 May 2024
Last updated 6 February 2025