Component

Filter summary

Displays a summary of applied filters as links that can remove a specific filter. Also a link for clearing all filters.

Search for usage of this component on GitHub.

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 attribute
  • data_attributes - accepts a hash of data attributes
  • aria - accepts a hash of aria attributes
  • classes - accepts a space separated string of classes, these should not be used for styling and must be prefixed with js-
  • margin_bottom - accepts a number from 0 to 9 (0px to 60px) using the GOV.UK Frontend spacing scale (defaults to no margin)
  • role - accepts a space separated string of roles
  • lang - accepts a language attribute value
  • open - 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’.