Summary expander

A component used to present summarised and tagged user details in an expander box.

Summary

Summary expander combines existing components from the NHS Digital service manual design system including tags, summary list, buttons and expander.

The expander is modified to allow placement of tags which are visible in both open and collapsed states but which are not part of the expander's toggle control.

The intention is to use this component when displaying a search result of multiple account details including admin status and other tags giving the user more than just a name to select by. Buttons can be set to perform any required action on the summary for example managing roles or changing a password.

The key difference is a separate container for summary tags. These remain visible at all times and do not gain a focus state.

Expander padding has been reduced and we recommend use of small buttons by including small: true when calling them.

<div class="tel-summary-expander" data-module="tel-summary-expander">
  <details class="nhsuk-details nhsuk-expander" open>
    <summary class="nhsuk-details__summary">
      <span class="nhsuk-details__summary-text"> Marsha Klein </span>

      <strong class="nhsuk-tag nhsuk-tag--grey tel-summary-expander__admin-tag">
        Admin
      </strong>

      <div class="tel-summary-expander__tags">
        <strong class="nhsuk-tag nhsuk-tag--red"> Inactive </strong>

        <strong class="nhsuk-tag nhsuk-tag--green"> Password set </strong>

        <strong class="nhsuk-tag nhsuk-tag--grey"> Admin </strong>

        <strong class="nhsuk-tag nhsuk-tag--grey">
          Registered by centre
        </strong>

        <strong class="nhsuk-tag nhsuk-tag--grey"> Claimed </strong>

        <strong class="nhsuk-tag nhsuk-tag--grey"> Verified </strong>
      </div>
    </summary>
    <div class="nhsuk-details__text">
      <dl class="nhsuk-summary-list">
        <div class="nhsuk-summary-list__row">
          <dt class="nhsuk-summary-list__key">Name</dt>
          <dd class="nhsuk-summary-list__value">Marsha Klein</dd>

          <dd class="nhsuk-summary-list__actions">
            <a class="nhsuk-link" href="#"
              >Change<span class="nhsuk-u-visually-hidden"> name</span></a
            >
          </dd>
        </div>

        <div class="nhsuk-summary-list__row">
          <dt class="nhsuk-summary-list__key">Date of birth</dt>
          <dd class="nhsuk-summary-list__value">11 April 1974</dd>

          <dd class="nhsuk-summary-list__actions">
            <a class="nhsuk-link" href="#"
              >Change<span class="nhsuk-u-visually-hidden">
                date of birth</span
              ></a
            >
          </dd>
        </div>

        <div class="nhsuk-summary-list__row">
          <dt class="nhsuk-summary-list__key">Contact information</dt>
          <dd class="nhsuk-summary-list__value">
            23 Meteor Street<br />London<br />
            N7 0QZ
          </dd>

          <dd class="nhsuk-summary-list__actions">
            <a class="nhsuk-link" href="#"
              >Change<span class="nhsuk-u-visually-hidden">
                contact information</span
              ></a
            >
          </dd>
        </div>

        <div class="nhsuk-summary-list__row">
          <dt class="nhsuk-summary-list__key">Contact details</dt>
          <dd class="nhsuk-summary-list__value">
            <p>07654 123123</p>
            <p>marsha.klein@example.com</p>
          </dd>

          <dd class="nhsuk-summary-list__actions">
            <a class="nhsuk-link" href="#"
              >Change<span class="nhsuk-u-visually-hidden">
                contact details</span
              ></a
            >
          </dd>
        </div>
      </dl>

      <div class="tel-summary-expander__actions nhsuk-button-group">
        <a
          class="nhsuk-button nhsuk-button--small"
          data-module="nhsuk-button"
          href="#manage"
          role="button"
          draggable="false"
        >
          Manage delegate
        </a>

        <a
          class="nhsuk-button nhsuk-button--secondary-solid nhsuk-button--small"
          data-module="nhsuk-button"
          href="#password"
          role="button"
          draggable="false"
        >
          Set password
        </a>
      </div>
    </div>
  </details>
</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.

{% from 'tel/components/summary-expander/macro.njk' import telSummaryExpander %}

{{ telSummaryExpander({
  expander_title: "Marsha Klein",
  is_admin: true,
  open: true,

  summary_list: {
    rows: [
      {
        key: {
          text: "Name"
        },
        value: {
          text: "Marsha Klein"
        },
        actions: {
          items: [
            {
              href: "#",
              text: "Change",
              visuallyHiddenText: "name"
            }
          ]
        }
      },
      {
        key: {
          text: "Date of birth"
        },
        value: {
          text: "11 April 1974"
        },
        actions: {
          items: [
            {
              href: "#",
              text: "Change",
              visuallyHiddenText: "date of birth"
            }
          ]
        }
      },
      {
        key: {
          text: "Contact information"
        },
        value: {
          html: "23 Meteor Street<br>London<br> N7 0QZ"
        },
        actions: {
          items: [
            {
              href: "#",
              text: "Change",
              visuallyHiddenText: "contact information"
            }
          ]
        }
      },
      {
        key: {
          text: "Contact details"
        },
        value: {
          html: "<p>07654 123123</p><p>marsha.klein@example.com</p>"
        },
        actions: {
          items: [
            {
              href: "#",
              text: "Change",
              visuallyHiddenText: "contact details"
            }
          ]
        }
      }
    ]
  }, 

  tags: [
      {
        text: "Inactive",
        colour: "red"
      },
      {
        text: "Password set",
        colour: "green"
      },
      {
        text: "Admin",
        colour: "grey"
      },
      {
        text: "Registered by centre",
        colour: "grey"
      },
      {
        text: "Claimed",
        colour: "grey"
      },
      {
        text: "Verified",
        colour: "grey"
      }
  ],

  buttons: [
      {
        text: "Manage delegate",
        href: "#manage",
        small: true
      },
      {
        text: "Set password",
        href: "#password",
        variant: "secondary-solid",
        small: true
      }
  ]
  
  }) }}

Macro options

Summary expander properties

  • expander_title (string, required) - The text displayed on the expander toggle header
  • is_admin (boolean) - When set to true, displays a distinct "Admin" tag floated to the right of the expander header, independent of the tags array
  • tags (array) - An array of tag objects displayed inside the header tag container. Each object accepts standard NHS.UK Tag macro options (for example, text, colour, classes)
  • buttons (array) - An array of button objects rendered within the expander action area. Each object accepts standard NHS.UK Button macro options (for example, text, href, variant). We recommend setting small: true for actions inside this component
  • summary_list (object) - Configuration object passed directly to render the internal definition list. Accepts all standard NHS.UK Summary list macro options (for example, rows, key, value, actions)
  • open (boolean) - Set to true if the expander should be expanded by default; defaults to false