Skip to main content
Preview This is a design system preview environment for main branch

Internal review app NHS.UK frontend

Use design system guidance and examples to build consistent, accessible NHS services for the public and staff.

Error message

These examples are used for automated tests and may not follow service manual best practice.

Error: Enter your full name

Code

Markup

<p class="nhsuk-error-message">
  <span class="nhsuk-u-visually-hidden">Error: </span>Enter your full name
</p>

Macro

{% from "error-message/macro.njk" import errorMessage -%}

{{ errorMessage({
  text: "Enter your full name"
}) }}

Error: Postcode must not include & and <

Code

Markup

<p class="nhsuk-error-message">
  <span class="nhsuk-u-visually-hidden">Error: </span>Postcode must not include &amp; and &lt;
</p>

Macro

{% from "error-message/macro.njk" import errorMessage -%}

{{ errorMessage({
  html: "Postcode must not include &amp; and &lt;"
}) }}

Error: Postcode must not include & and <

Code

Markup

<p class="nhsuk-error-message">
  <span class="nhsuk-u-visually-hidden">Error: </span>Postcode must not include &amp; and &lt;
</p>

Macro

{% from "error-message/macro.njk" import errorMessage -%}

{% call errorMessage() -%}
Postcode must not include &amp; and &lt;
{%- endcall %}

There is an error on line 42

Code

Markup

<p class="nhsuk-error-message">
  There is an error on line 42
</p>

Macro

{% from "error-message/macro.njk" import errorMessage -%}

{{ errorMessage({
  text: "There is an error on line 42",
  visuallyHiddenText: ""
}) }}

Error: Postcode must not include & and <

Code

Markup

<p class="nhsuk-error-message">
  <span class="nhsuk-u-visually-hidden">Error: </span>Postcode must not include &amp; and &lt;
</p>

Macro

{% from "error-message/macro.njk" import errorMessage -%}

{{ errorMessage({
  text: "Postcode must not include & and <"
}) }}

Gwall: Rhowch eich enw llawn

Code

Markup

<p class="nhsuk-error-message">
  <span class="nhsuk-u-visually-hidden">Gwall: </span>Rhowch eich enw llawn
</p>

Macro

{% from "error-message/macro.njk" import errorMessage -%}

{{ errorMessage({
  text: "Rhowch eich enw llawn",
  visuallyHiddenText: "Gwall"
}) }}