1. Component Guide
  2. Share links
  3. With data attributes
Share links example

With data attributes

Data attributes can be added to both the parent element and the individual share links, as shown. Note that the component defaults to having a data-module of gem-track-click, but this is preserved even if another value for module is passed.

How it looks (preview)

How to call this example

<%= render "govuk_publishing_components/components/share_links", {
  data_attributes: {
    module: "example-passed-module"
  },
  links: [
    {
      href: "/facebook-share-link",
      text: "Facebook",
      icon: "facebook",
      data_attributes: {
        meeting: "hello"
      }
    },
    {
      href: "/twitter-share-link",
      text: "Twitter",
      icon: "twitter",
      data_attributes: {
        departing: "goodbye"
      }
    }
  ]
} %>