Details
Make a page easier to scan by letting users reveal more detailed information only if they need it
How it looks (preview) (preview all)
Help with nationality
How to call this component
<%= render "govuk_publishing_components/components/details", {
title: "Help with nationality"
} do %>
We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.
<% end %>
GOV.UK Design System
This component incorporates components from the GOV.UK Design System:
Accessibility acceptance criteria
The component must:
- accept focus
- be focusable with a keyboard
- be usable with a keyboard
- be usable with touch
- indicate when it has focus
- toggle the visibility of the details element’s content when interacted with
- indicate the expanded state when details’ content is visible
- indicate the collapsed state when details’ content is hidden
Links in the component must:
- accept focus
- be focusable with a keyboard
- be usable with a keyboard
- indicate when they have focus
- change in appearance when touched (in the touch-down state)
- change in appearance when hovered
- be usable with touch
- be usable with voice commands
- have visible text
- have meaningful text
Other examples
With aria attributes (preview)
Aria attributes can be applied to the summary element of the component.
Attorney General's office
Works with 2 agencies and public bodies
- Department 1
- Department 2
<div>
<p class="govuk-body">Attorney General's office</p>
<%= render "govuk_publishing_components/components/details", {
title: "Works with 2 agencies and public bodies",
summary_aria_attributes: {
label: "Attorney General's office"
}
} do %>
<ul>
<li>Department 1</li>
<li>Department 2</li>
</ul>
<% end %>
</div>
With gtm tracking (preview)
Applies a tracking attribute specifically for use by Google Tag Manager in Content Publisher.
Help with nationality
<%= render "govuk_publishing_components/components/details", {
title: "Help with nationality",
data_attributes: {
tracking: "GTM-123AB"
}
} do %>
We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.
<% end %>
With ga4 tracking (preview)
GA4 tracking is mostly handled internally by the component, apart from the required attribute index_section_count
. This records the number of details components on the page and must be passed by the hosting application. Other GA4 attributes can also be passed if required, including to override attributes set by the component (for some reason this doesn’t work in the component guide but works in applications).
The tracking automatically includes index_section
as the index of the component on the page compared with other instances of the component that are also being tracked, e.g. the first details component on a page will be index_section
1, the second index_section
2, etc.
Link tracking for the contents of the details component is not included due to varying tracking requirements. If you need to track links in the component, wrap it in the application with the GA4 link tracker.
What did the ground say to the train?
<%= render "govuk_publishing_components/components/details", {
title: "What did the ground say to the train?",
ga4_attributes: {
index_section_count: 6,
type: "not the default"
}
} do %>
Between you and me, I've been tracked.
<% end %>
Disable ga4 tracking (preview)
Disables GA4 tracking on the component. Tracking is enabled by default.
No tracking here
<%= render "govuk_publishing_components/components/details", {
title: "No tracking here",
disable_ga4: true
} do %>
Or here, but thanks for looking.<% end %>
Open (preview)
Help with nationality
<%= render "govuk_publishing_components/components/details", {
title: "Help with nationality",
open: true
} do %>
We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.
<% end %>