Expander
Use an expander to break down information into bitesize pieces which the user can 'expand' when they're ready to do so.
<details class="hse-details hse-expander">
<summary class="hse-details__summary">
<span class="hse-details__summary-text">
Get your medical records
</span>
</summary>
<div class="hse-details__text">
<p>You can see your GP records by:</p>
<ul>
<li>asking for them at your GP surgery </li>
<li>going online to see them (if you have signed up for <a href="/using-the-hse/hse-services/gps/gp-online-services/">GP online services</a>) </li>
</ul>
</div>
</details>
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 | Required | Description |
---|---|---|---|
Name text | Type string | Required true | Description Text to be displayed on the details component. |
Name html | Type string | Required true | Description HTML content to be displayed within the details component. |
Name id | Type string | Required false | Description Id to add to the details element. |
Name open | Type boolean | Required false | Description If true, details element will be expanded. |
Name classes | Type string | Required false | Description Classes to add to the details element. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the details element. |
{% from 'details/macro.njk' import details %}
{{ details({
"classes": "hse-expander",
"text": "Get your medical records",
"HTML": "
<p>You can see your GP records by:</p>
<ul>
<li>asking for them at your GP surgery </li>
<li>going online to see them (if you have signed up for <a href=\"/using-the-hse/hse-services/gps/gp-online-services/\">GP online services</a>) </li>
</ul>"
}) }}
An expander is 1 of 2 ways to let users reveal more information. The other is details.
When to use expanders
Use expanders:
- on pages where users may find the amount of information overwhelming
- for information for a wide audience, unlike the details component
- when you see a clear user need for them
Test your content without an expander first.
It may be better to:
- simplify and reduce the amount of content
- split the content across multiple pages
- keep the content on a single page, separated by headings
- use a list of links to let users navigate quickly to specific sections of content
- avoid using expanders for geographical (county by county) information - use a Service Finder instead
When not to use an expander
Do not use an expander:
- if only some of your users will need the information - use details instead
- to give users help in forms - instead, add hint text as a part of other form inputs, such as text inputs, radios and checkboxes or use details
- on pages with other interactive elements, such as buttons or text input - there's a risk that expanders will distract users
- inside other patterns, for example to help users decide when and where to get care (care cards)
How expanders work
The expander is a short link in a box that expands into more detailed text when a user clicks on it.
More than 1 expander
It can work well to have several expanders.
<div class="hse-expander-group">
<details class="hse-details hse-expander">
<summary class="hse-details__summary">
<span class="hse-details__summary-text">
How to measure your blood glucose levels
</span>
</summary>
<div class="hse-details__text">
<p>Testing your blood at home is quick and easy, although it can be uncomfortable. It does get better.</p>
<p>You would have been given:</p>
<ul>
<li>a blood glucose metre</li>
<li>small needles called lancets</li>
<li>a plastic pen to hold the lancets</li>
<li>small test strips</li>
</ul>
</div>
</details>
<details class="hse-details hse-expander">
<summary class="hse-details__summary">
<span class="hse-details__summary-text">
When to check your blood glucose level
</span>
</summary>
<div class="hse-details__text">
<p>Try to check your blood:</p>
<ul>
<li>before meals</li>
<li>2 to 3 hours after meals</li>
<li>before, during (take a break) and after exercise</li>
</ul>
<p>This helps you understand your blood glucose levels and how they’re affected by meals and exercise. It should help you have more stable blood glucose levels.</p>
</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.
Name | Type | Required | Description |
---|---|---|---|
Name text | Type string | Required true | Description Text to be displayed on the details component. |
Name html | Type string | Required true | Description HTML content to be displayed within the details component. |
Name id | Type string | Required false | Description Id to add to the details element. |
Name open | Type boolean | Required false | Description If true, details element will be expanded. |
Name classes | Type string | Required false | Description Classes to add to the details element. |
Name attributes | Type object | Required false | Description HTML attributes (for example data attributes) to add to the details element. |
{% from 'details/macro.njk' import details %}
<div class="hse-expander-group">
{{ details({
"classes": "hse-expander",
"text": "How to measure your blood glucose levels",
"HTML": "
<p>Testing your blood at home is quick and easy, although it can be uncomfortable. It does get better.</p>
<p>You would have been given:</p>
<ul>
<li>a blood glucose metre</li>
<li>small needles called lancets</li>
<li>a plastic pen to hold the lancets</li>
<li>small test strips</li>
</ul>
"
}) }}
{{ details({
"classes": "hse-expander",
"text": "When to check your blood glucose level",
"HTML": "
<p>Try to check your blood:</p>
<ul>
<li>before meals</li>
<li>2 to 3 hours after meals</li>
<li>before, during (take a break) and after exercise</li>
</ul>
<p>This helps you understand your blood glucose levels and how they’re affected by meals and exercise. It should help you have more stable blood glucose levels.</p>
"
}) }}
</div>
Write clear link text
Make the link text short and descriptive so users can quickly work out if they need to click on it.
Updated: February 2024