This is content for accordion 1 of 2
This content contains a link
Some apps require custom id
s per accordion section heading. Custom id
s allow you to link section headings, sometimes across multiple pages.
For example on guidance pages for Content Designers, referred to as “manuals”, each manual includes multiple sets of accordions and will reference between specific sections to easily access content.
Using the same rules, custom id
s automatically open accordions when users click within another accordion that links to either
id
of an accordion section headingid
within the content of an accordion (this will also automatically navigate to and open accordions on page load)This feature will only be used if the anchor_navigation
flag is passed as true
. This mitigates performance risk from event listeners on a large number of links.
Unlike with the accordion-wide custom id
attribute, any id
s passed to accordion headings as part of this are not stored in localStorage
. id
s do not need to be unique across your domain, but should still be unique in the context of the page.
This is content for accordion 1 of 2
This content contains a link
This is the content for Know your audience.
This is the content for How people read.
<%= render "govuk_publishing_components/components/accordion", {
anchor_navigation: true,
items: [
{
heading: {
text: "Writing well for the web",
id: "writing-well-for-the-web-1"
},
content: {
html: sanitize("<p class=\"govuk-body\">This is content for accordion 1 of 2</p><p class=\"govuk-body\">This content contains a <a href=\"#anchor-nav-test-1\" class=\"govuk-link\">link</a></p>")
}
},
{
heading: {
text: "Writing well for specialists"
},
content: {
html: sanitize("<p class=\"govuk-body\" id=\"anchor-nav-test-1\">This is content for accordion 2 of 2</p>")
}
},
{
heading: {
text: "Know your audience"
},
content: {
html: sanitize("<p class=\"govuk-body\">This is the content for Know your audience.</p>")
}
},
{
heading: {
text: "How people read"
},
content: {
html: sanitize("<p class=\"govuk-body\">This is the content for How people read.</p>")
}
}
]
} %>