Skip to main content

This is an internal development app.

To learn how to design and build digital services, visit the design system in the NHS digital service manual for guidance and examples.

Error summary

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

Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-day">
            Date of birth must be in the past
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    text: "There is a problem"
  },
  errorList: [
    {
      text: "Date of birth must be in the past",
      href: "#example-day"
    }
  ]
}) }}

Error summary with description

Open this example in a new tab: Error summary with description

There is a problem

Describe the errors and how to correct them

Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <p>
        Describe the errors and how to correct them
      </p>
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-day">
            Date of birth must be in the past
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    text: "There is a problem"
  },
  description: {
    text: "Describe the errors and how to correct them"
  },
  errorList: [
    {
      text: "Date of birth must be in the past",
      href: "#example-day"
    }
  ]
}) }}

Error summary with description HTML

Open this example in a new tab: Error summary with description HTML

There is a problem

Describe the errors and how to correct them

Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <p>
        Describe the errors and <span>how to correct them</span>
      </p>
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-day">
            Date of birth must be in the past
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    text: "There is a problem"
  },
  description: {
    html: "Describe the errors and <span>how to correct them</span>"
  },
  errorList: [
    {
      text: "Date of birth must be in the past",
      href: "#example-day"
    }
  ]
}) }}

Error summary with description only

Open this example in a new tab: Error summary with description only

There is a problem

Describe the errors and how to correct them

Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <p>
        Describe the errors and how to correct them
      </p>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    text: "There is a problem"
  },
  description: {
    text: "Describe the errors and how to correct them"
  }
}) }}

Error summary with description via call block

Open this example in a new tab: Error summary with description via call block

There is a problem

Describe the errors and how to correct them

Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <p>
Describe the errors and <span>how to correct them</span>
      </p>
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-day">
            Date of birth must be in the past
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{% call errorSummary({
  heading: {
    text: "There is a problem"
  },
  errorList: [
    {
      text: "Date of birth must be in the past",
      href: "#example-day"
    }
  ]
}) %}
Describe the errors and <span>how to correct them</span>
{%- endcall %}
Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-first-name">
            Enter your first name
          </a>
        </li>
        <li>
          <a href="#example-last-name">
            Enter your last name
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    text: "There is a problem"
  },
  errorList: [
    {
      text: "Enter your first name",
      href: "#example-first-name"
    },
    {
      text: "Enter your last name",
      href: "#example-last-name"
    }
  ]
}) }}
Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a problem
    </h2>
    <div class="nhsuk-error-summary__body">
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-first-name">
            Enter your first name
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    text: "There is a problem"
  },
  errorList: [
    {
      text: "Enter your first name",
      href: "#example-first-name"
    },
    false
  ]
}) }}
Code

Markup

<div class="nhsuk-error-summary" data-module="nhsuk-error-summary">
  <div role="alert">
    <h2 class="nhsuk-error-summary__title">
      There is a <span>problem</span>
    </h2>
    <div class="nhsuk-error-summary__body">
      <ul class="nhsuk-list nhsuk-error-summary__list">
        <li>
          <a href="#example-day">
            Date of birth must be in the past
          </a>
        </li>
      </ul>
    </div>
  </div>
</div>

Macro

{% from "error-summary/macro.njk" import errorSummary -%}

{{ errorSummary({
  heading: {
    html: "There is a <span>problem</span>"
  },
  errorList: [
    {
      text: "Date of birth must be in the past",
      href: "#example-day"
    }
  ]
}) }}