Component

List

A list - unordered or ordered, with or without counters / bullet points.

This is an ordered or unordered list, with or without visible bullets / numbers.

The items parameter can include HTML to display - such as links or another list. This HTML can either be directly coded or come from another component.

Search for usage of this component on GitHub.

How it looks (preview) (preview all)

  • Tony’s Chocolonely
  • Cherry Ripe
  • Snickers
  • Chomp
  • Penguin
  • Boost

How to call this component

<%= render "govuk_publishing_components/components/list", {
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

GOV.UK Design System

This component incorporates components from the GOV.UK Design System:

Accessibility acceptance criteria

The list must:

  • inform the user how many items are in the list
  • convey the content structure
  • indicate the current page when contents span different pages, and not link to itself

The list may:

  • include an aria-label to contextualise the list if helpful

Other examples

Unordered list with aria-label (preview)

A list with an aria-label

  • Tony’s Chocolonely
  • Cherry Ripe
  • Snickers
  • Chomp
  • Penguin
  • Boost
<%= render "govuk_publishing_components/components/list", {
  aria_label: "A list of delicious chocolate bars.",
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

Unordered list with bullet points (preview)

An unordered list with visible bullet points.

  • Tony’s Chocolonely
  • Cherry Ripe
  • Snickers
  • Chomp
  • Penguin
  • Boost
<%= render "govuk_publishing_components/components/list", {
  visible_counters: true,
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

Ordered list without numbers (preview)

This is an ordered list where the numbers aren’t visible.

  1. Tony’s Chocolonely
  2. Cherry Ripe
  3. Snickers
  4. Chomp
  5. Penguin
  6. Boost
<%= render "govuk_publishing_components/components/list", {
  list_type: "number",
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

Ordered list with numbers (preview)

This is an ordered list with the numbers visible.

  1. Tony’s Chocolonely
  2. Cherry Ripe
  3. Snickers
  4. Chomp
  5. Penguin
  6. Boost
<%= render "govuk_publishing_components/components/list", {
  list_type: "number",
  visible_counters: true,
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

With extra spacing (preview)

Increases the amount of spacing between the list items.

  • Tony’s Chocolonely
  • Cherry Ripe
  • Snickers
  • Chomp
  • Penguin
  • Boost
<%= render "govuk_publishing_components/components/list", {
  extra_spacing: true,
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

With id attribute (preview)

Sets the id on the ul or ol element.

  • Tony’s Chocolonely
  • Cherry Ripe
  • Snickers
  • Chomp
  • Penguin
  • Boost
<%= render "govuk_publishing_components/components/list", {
  id: "super-fantastic-chocolate-list",
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>

With margin (preview)

Sets the margin on the bottom of the list element.

The component accepts a number for margin bottom from 0 to 9 (0px to 60px) using the GOV.UK Frontend spacing scale. It defaults to having a 20px margin.

  • Tony’s Chocolonely
  • Cherry Ripe
  • Snickers
  • Chomp
  • Penguin
  • Boost
<%= render "govuk_publishing_components/components/list", {
  margin_bottom: 9,
  items: [
    sanitize("Tony&rsquo;s Chocolonely"),
    sanitize("<a href=\"https://en.wikipedia.org/wiki/Cherry_Ripe_(chocolate_bar)\" rel=\"noopener\" class=\"govuk-link\">Cherry Ripe</a>"),
    "Snickers",
    "Chomp",
    "Penguin",
    "Boost"
  ]
} %>