Filter summary
Displays a summary of applied filters as links that can remove a specific filter. Also a link for clearing all filters.
How it looks (preview) (preview all)
How to call this component
<%= render "components/filter_summary", {
reset_link_href: "#",
reset_link_text: "Clear all filters",
heading_level: 3,
heading_text: "Selected filters",
filters: [
{
label: "Filter 1",
value: "Value 1",
remove_href: "#",
visually_hidden_prefix: "Remove filter"
},
{
label: "Filter 2",
value: "Value 2",
remove_href: "#",
visually_hidden_prefix: "Remove filter"
},
{
label: "Filter 3",
value: "Value that is so long that the styling needs to handle it correctly",
remove_href: "#",
visually_hidden_prefix: "Remove filter"
}
]
} %>
Accessibility acceptance criteria
The component items must:
- accept focus
- be focusable with a keyboard
- be usable with a keyboard
- be usable with touch
- indicate when it has focus
Other examples
Standard options
This component uses the component wrapper helper. It accepts the following options and applies them to the parent element of the component. See the component wrapper helper documentation for more detail.
id
- accepts a string for the element ID attributedata_attributes
- accepts a hash of data attributesaria
- accepts a hash of aria attributesclasses
- accepts a space separated string of classes, these should not be used for styling and must be prefixed withjs-
margin_bottom
- accepts a number from0
to9
(0px
to60px
) using the GOV.UK Frontend spacing scale (defaults to no margin)role
- accepts a space separated string of roleslang
- accepts a language attribute valueopen
- accepts an open attribute value (true or false)hidden
- accepts an empty string, ‘hidden’, or ‘until-found’tabindex
- accepts an integer. The integer can also be passed as a string.dir
- accepts ‘rtl’, ‘ltr’, or ‘auto’.