1. Component Guide
  2. Select
  3. With data attributes
Select example

With data attributes

Other data attributes can be passed to the component if needed.

How it looks (preview)

How to call this example

<%= render "govuk_publishing_components/components/select", {
  id: "dropdown4",
  label: "With data attributes",
  options: [
    {
      text: "Option one",
      value: "option1",
      data_attributes: {
        another_attribute: "attribute 1",
        something_else: "attribute 2"
      }
    },
    {
      text: "Option two",
      value: "option2"
    },
    {
      text: "Option three",
      value: "option3"
    }
  ]
} %>