Skip to main content
Preview This is a design system preview environment for main branch

Internal review app NHS.UK frontend

Use design system guidance and examples to build consistent, accessible NHS services for the public and staff.

Radios

These examples are used for automated tests and may not follow service manual best practice.

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="example">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="example-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="example-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="example">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="example-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="example-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled" name="example" type="radio" value="email" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-2" name="example" type="radio" value="phone" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-3" name="example" type="radio" value="text" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  idPrefix: "disabled",
  name: "example",
  disabled: true,
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled" name="example" type="radio" value="email" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-2" name="example" type="radio" value="phone" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-3" name="example" type="radio" value="text" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  idPrefix: "disabled",
  name: "example",
  disabled: true,
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-input" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-input">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-input-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-input-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-input-3" name="example" type="radio" value="text" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-input-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  idPrefix: "disabled-input",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message",
      disabled: true
    }
  ]
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-input" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-input">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-input-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-input-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-input-3" name="example" type="radio" value="text" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-input-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  idPrefix: "disabled-input",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message",
      disabled: true
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-enabled-input" name="example" type="radio" value="email" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-enabled-input">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-enabled-input-2" name="example" type="radio" value="phone" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-enabled-input-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-enabled-input-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-enabled-input-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  idPrefix: "disabled-enabled-input",
  name: "example",
  disabled: true,
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message",
      disabled: false
    }
  ]
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-enabled-input" name="example" type="radio" value="email" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-enabled-input">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-enabled-input-2" name="example" type="radio" value="phone" disabled>
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-enabled-input-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="disabled-enabled-input-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="disabled-enabled-input-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  idPrefix: "disabled-enabled-input",
  name: "example",
  disabled: true,
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message",
      disabled: false
    }
  ],
  small: true
}) }}

Are you 18 or over?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      Are you 18 or over?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--inline" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="inline" name="example" type="radio" value="yes">
      <label class="nhsuk-label nhsuk-radios__label" for="inline">
        Yes
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="inline-2" name="example" type="radio" value="no">
      <label class="nhsuk-label nhsuk-radios__label" for="inline-2">
        No
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Are you 18 or over?",
      size: "l"
    }
  },
  idPrefix: "inline",
  name: "example",
  inline: true,
  items: [
    {
      value: "yes",
      text: "Yes"
    },
    {
      value: "no",
      text: "No"
    }
  ]
}) }}

Are you 18 or over?

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      Are you 18 or over?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small nhsuk-radios--inline" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="inline" name="example" type="radio" value="yes">
      <label class="nhsuk-label nhsuk-radios__label" for="inline">
        Yes
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="inline-2" name="example" type="radio" value="no">
      <label class="nhsuk-label nhsuk-radios__label" for="inline-2">
        No
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Are you 18 or over?",
      size: "m"
    }
  },
  idPrefix: "inline",
  name: "example",
  inline: true,
  items: [
    {
      value: "yes",
      text: "Yes"
    },
    {
      value: "no",
      text: "No"
    }
  ],
  small: true
}) }}
How do you want to be contacted about this?
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--s">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: "s"
    }
  },
  idPrefix: "custom-size",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}
How do you want to be contacted about this?
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  idPrefix: "custom-size",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}
How do you want to be contacted about this?
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  idPrefix: "custom-size",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}
How do you want to be contacted about this?
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--xl">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="custom-size-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="custom-size-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: "xl"
    }
  },
  idPrefix: "custom-size",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Before
After
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <samp class="app-annotate">Before</samp>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="example">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="example-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="example-3">
        Text message
      </label>
    </div>
  <samp class="app-annotate">After</samp>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  formGroup: {
    beforeInputs: {
      html: '<samp class="app-annotate">Before</samp>'
    },
    afterInputs: {
      html: '<samp class="app-annotate">After</samp>'
    }
  }
}) }}

How do you want to be contacted about this?

Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ],
  small: true
}) }}

What is your favourite colour?

I like red

I like green

I like blue

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      What is your favourite colour?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-strings" name="example" type="radio" value="red" data-aria-controls="conditional-conditional-strings">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-strings">
        Red
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-strings">
      <p>I like red</p>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-strings-2" name="example" type="radio" value="green" data-aria-controls="conditional-conditional-strings-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-strings-2">
        Green
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-strings-2">
      <p>I like green</p>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-strings-3" name="example" type="radio" value="blue" data-aria-controls="conditional-conditional-strings-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-strings-3">
        Blue
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-strings-3">
      <p>I like blue</p>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "What is your favourite colour?",
      size: "l"
    }
  },
  idPrefix: "conditional-strings",
  name: "example",
  items: [
    {
      value: "red",
      text: "Red",
      conditional: "I like red"
    },
    {
      value: "green",
      text: "Green",
      conditional: "I like green"
    },
    {
      value: "blue",
      text: "Blue",
      conditional: "I like blue"
    }
  ]
}) }}

What is your favourite colour?

I like red

I like green

I like blue

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      What is your favourite colour?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-strings" name="example" type="radio" value="red" data-aria-controls="conditional-conditional-strings">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-strings">
        Red
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-strings">
      <p>I like red</p>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-strings-2" name="example" type="radio" value="green" data-aria-controls="conditional-conditional-strings-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-strings-2">
        Green
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-strings-2">
      <p>I like green</p>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-strings-3" name="example" type="radio" value="blue" data-aria-controls="conditional-conditional-strings-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-strings-3">
        Blue
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-strings-3">
      <p>I like blue</p>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "What is your favourite colour?",
      size: "m"
    }
  },
  idPrefix: "conditional-strings",
  name: "example",
  items: [
    {
      value: "red",
      text: "Red",
      conditional: "I like red"
    },
    {
      value: "green",
      text: "Green",
      conditional: "I like green"
    },
    {
      value: "blue",
      text: "Blue",
      conditional: "I like blue"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint conditional-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="conditional-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "conditional",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint conditional-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="conditional-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "conditional",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ],
  small: true
}) }}

Radios with conditional content, error message (nested)

Open this example in a new tab: Radios with conditional content, error message (nested)

How do you want to be contacted about this?

Select 1 option

Error: Enter your phone number

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" checked data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional" id="conditional-conditional-2">
<div class="nhsuk-form-group nhsuk-form-group--error">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <p class="nhsuk-error-message" id="contact-by-phone-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Enter your phone number
  </p>
  <input class="nhsuk-input nhsuk-input--error nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel" aria-describedby="contact-by-phone-error">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional",
  name: "example",
  value: "phone",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group nhsuk-form-group--error">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <p class="nhsuk-error-message" id="contact-by-phone-error">\n    <span class="nhsuk-u-visually-hidden">Error: </span>Enter your phone number\n  </p>\n  <input class="nhsuk-input nhsuk-input--error nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel" aria-describedby="contact-by-phone-error">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ]
}) }}

Radios small with conditional content, error message (nested)

Open this example in a new tab: Radios small with conditional content, error message (nested)

How do you want to be contacted about this?

Select 1 option

Error: Enter your phone number

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" checked data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional" id="conditional-conditional-2">
<div class="nhsuk-form-group nhsuk-form-group--error">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <p class="nhsuk-error-message" id="contact-by-phone-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Enter your phone number
  </p>
  <input class="nhsuk-input nhsuk-input--error nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel" aria-describedby="contact-by-phone-error">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional",
  name: "example",
  value: "phone",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group nhsuk-form-group--error">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <p class="nhsuk-error-message" id="contact-by-phone-error">\n    <span class="nhsuk-u-visually-hidden">Error: </span>Enter your phone number\n  </p>\n  <input class="nhsuk-input nhsuk-input--error nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel" aria-describedby="contact-by-phone-error">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ],
  small: true
}) }}

Do you know your NHS number?

This is a 10 digit number (like 999 123 4567) that you can find on an NHS letter, prescription or in the NHS App
or
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-divider-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      Do you know your NHS number?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-divider-hint">
    This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-divider" name="example" type="radio" value="yes">
      <label class="nhsuk-label nhsuk-radios__label" for="with-divider">
        Yes, I know my NHS number
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-divider-2" name="example" type="radio" value="no">
      <label class="nhsuk-label nhsuk-radios__label" for="with-divider-2">
        No, I do not know my NHS number
      </label>
    </div>
    <div class="nhsuk-radios__divider">or</div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-divider-4" name="example" type="radio" value="not sure">
      <label class="nhsuk-label nhsuk-radios__label" for="with-divider-4">
        I&#39;m not sure
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Do you know your NHS number?",
      size: "l"
    }
  },
  hint: {
    html: 'This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App'
  },
  idPrefix: "with-divider",
  name: "example",
  items: [
    {
      value: "yes",
      text: "Yes, I know my NHS number"
    },
    {
      value: "no",
      text: "No, I do not know my NHS number"
    },
    {
      divider: "or"
    },
    {
      value: "not sure",
      text: "I'm not sure"
    }
  ]
}) }}

Do you know your NHS number?

This is a 10 digit number (like 999 123 4567) that you can find on an NHS letter, prescription or in the NHS App
or
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-divider-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      Do you know your NHS number?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-divider-hint">
    This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App
  </div>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-divider" name="example" type="radio" value="yes">
      <label class="nhsuk-label nhsuk-radios__label" for="with-divider">
        Yes, I know my NHS number
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-divider-2" name="example" type="radio" value="no">
      <label class="nhsuk-label nhsuk-radios__label" for="with-divider-2">
        No, I do not know my NHS number
      </label>
    </div>
    <div class="nhsuk-radios__divider">or</div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-divider-4" name="example" type="radio" value="not sure">
      <label class="nhsuk-label nhsuk-radios__label" for="with-divider-4">
        I&#39;m not sure
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Do you know your NHS number?",
      size: "m"
    }
  },
  hint: {
    html: 'This is a 10 digit number (like <span class="nhsuk-u-nowrap">999 123 4567</span>) that you can find on an NHS letter, prescription or in the NHS App'
  },
  idPrefix: "with-divider",
  name: "example",
  items: [
    {
      value: "yes",
      text: "Yes, I know my NHS number"
    },
    {
      value: "no",
      text: "No, I do not know my NHS number"
    },
    {
      divider: "or"
    },
    {
      value: "not sure",
      text: "I'm not sure"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-error-message-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-error-message",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-error-message-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-error-message",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-error-hint with-hint-error-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-hint-error-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="with-hint-error-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-hint-error",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-error-hint with-hint-error-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-hint-error-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="with-hint-error-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-hint-error",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-error-hint with-hint-error-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-hint-error-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="with-hint-error-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: "Select 1 option",
  errorMessage: "Select how you want to be contacted",
  idPrefix: "with-hint-error",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-error-hint with-hint-error-error">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-hint-error-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="with-hint-error-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: "Select 1 option",
  errorMessage: "Select how you want to be contacted",
  idPrefix: "with-hint-error",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}
How do you want to be contacted about this?
Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-error-hint with-hint-error-error">
  <legend class="nhsuk-fieldset__legend">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-hint" id="with-hint-error-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="with-hint-error-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: null
    }
  },
  hint: {
    text: "Select 1 option"
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-hint-error",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

Radios small with error message and hint, without heading

Open this example in a new tab: Radios small with error message and hint, without heading

How do you want to be contacted about this?
Select 1 option

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-error-hint with-hint-error-error">
  <legend class="nhsuk-fieldset__legend">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-hint" id="with-hint-error-hint">
    Select 1 option
  </div>
  <p class="nhsuk-error-message" id="with-hint-error-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-error-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-error-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: null
    }
  },
  hint: {
    text: "Select 1 option"
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-hint-error",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}
How do you want to be contacted about this?

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-error-message-error">
  <legend class="nhsuk-fieldset__legend">
    How do you want to be contacted about this?
  </legend>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: null
    }
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-error-message",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}
How do you want to be contacted about this?

Error: Select how you want to be contacted

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-error-message-error">
  <legend class="nhsuk-fieldset__legend">
    How do you want to be contacted about this?
  </legend>
  <p class="nhsuk-error-message" id="with-error-message-error">
    <span class="nhsuk-u-visually-hidden">Error: </span>Select how you want to be contacted
  </p>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-message-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-message-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      text: "How do you want to be contacted about this?",
      size: null
    }
  },
  errorMessage: {
    text: "Select how you want to be contacted"
  },
  idPrefix: "with-error-message",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Code

Markup

<div class="nhsuk-form-group nhsuk-form-group--error">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-only" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-only">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-only-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-only-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-error-only-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-error-only-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  errorMessage: true,
  idPrefix: "with-error-only",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-hint-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "with-hint",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="with-hint-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="with-hint-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "with-hint",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ],
  small: true
}) }}

Do you have a mobile phone with signal?

We will text you a 6 digit security code
We will call you to give you a 6 digit security code
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      Do you have a mobile phone with signal?
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-item" name="example" type="radio" value="mobile" aria-describedby="with-hint-item-item-hint">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-item">
        Yes, I have a mobile phone with signal
      </label>
      <div class="nhsuk-hint nhsuk-radios__hint" id="with-hint-item-item-hint">
        We will text you a 6 digit security code
      </div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-item-2" name="example" type="radio" value="landline" aria-describedby="with-hint-item-2-item-hint">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-item-2">
        No, I want to use my landline
      </label>
      <div class="nhsuk-hint nhsuk-radios__hint" id="with-hint-item-2-item-hint">
        We will call you to give you a 6 digit security code
      </div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Do you have a mobile phone with signal?",
      size: "l"
    }
  },
  idPrefix: "with-hint-item",
  name: "example",
  items: [
    {
      value: "mobile",
      text: "Yes, I have a mobile phone with signal",
      hint: {
        text: "We will text you a 6 digit security code"
      }
    },
    {
      value: "landline",
      text: "No, I want to use my landline",
      hint: {
        text: "We will call you to give you a 6 digit security code"
      }
    }
  ]
}) }}

Do you have a mobile phone with signal?

We will text you a 6 digit security code
We will call you to give you a 6 digit security code
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      Do you have a mobile phone with signal?
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-item" name="example" type="radio" value="mobile" aria-describedby="with-hint-item-item-hint">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-item">
        Yes, I have a mobile phone with signal
      </label>
      <div class="nhsuk-hint nhsuk-radios__hint" id="with-hint-item-item-hint">
        We will text you a 6 digit security code
      </div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-hint-item-2" name="example" type="radio" value="landline" aria-describedby="with-hint-item-2-item-hint">
      <label class="nhsuk-label nhsuk-radios__label" for="with-hint-item-2">
        No, I want to use my landline
      </label>
      <div class="nhsuk-hint nhsuk-radios__hint" id="with-hint-item-2-item-hint">
        We will call you to give you a 6 digit security code
      </div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Do you have a mobile phone with signal?",
      size: "m"
    }
  },
  idPrefix: "with-hint-item",
  name: "example",
  items: [
    {
      value: "mobile",
      text: "Yes, I have a mobile phone with signal",
      hint: {
        text: "We will text you a 6 digit security code"
      }
    },
    {
      value: "landline",
      text: "No, I want to use my landline",
      hint: {
        text: "We will call you to give you a 6 digit security code"
      }
    }
  ],
  small: true
}) }}

Venenatis Condimentum

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      Venenatis Condimentum
    </h1>
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-long-text" name="example" type="radio" value="nullam">
      <label class="nhsuk-label nhsuk-radios__label" for="with-long-text">
        Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo
        quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
        Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida
        at eget metus.
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-long-text-2" name="example" type="radio" value="aenean">
      <label class="nhsuk-label nhsuk-radios__label" for="with-long-text-2">
        Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis
        vestibulum. Donec sed odio dui. Duis mollis, est non commodo luctus,
        nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis
        natoque penatibus et magnis dis parturient montes, nascetur ridiculus
        mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam
        venenatis vestibulum. Cras mattis consectetur purus sit amet
        fermentum.
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-long-text-3" name="example" type="radio" value="fusce">
      <label class="nhsuk-label nhsuk-radios__label" for="with-long-text-3">
        Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum
        nibh, ut fermentum massa justo sit amet risus. Etiam porta sem
        malesuada magna mollis euismod. Praesent commodo cursus magna, vel
        scelerisque nisl consectetur et. Etiam porta sem malesuada magna
        mollis euismod. Etiam porta sem malesuada magna mollis euismod.
        Donec sed odio dui. Sed posuere consectetur est at lobortis.
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Venenatis Condimentum",
      size: "l"
    }
  },
  idPrefix: "with-long-text",
  name: "example",
  items: [
    {
      value: "nullam",
      text: "Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo\nquam. Pellentesque ornare sem lacinia quam venenatis vestibulum.\nMaecenas faucibus mollis interdum. Donec id elit non mi porta gravida\nat eget metus."
    },
    {
      value: "aenean",
      text: "Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis\nvestibulum. Donec sed odio dui. Duis mollis, est non commodo luctus,\nnisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis\nnatoque penatibus et magnis dis parturient montes, nascetur ridiculus\nmus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam\nvenenatis vestibulum. Cras mattis consectetur purus sit amet\nfermentum."
    },
    {
      value: "fusce",
      text: "Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum\nnibh, ut fermentum massa justo sit amet risus. Etiam porta sem\nmalesuada magna mollis euismod. Praesent commodo cursus magna, vel\nscelerisque nisl consectetur et. Etiam porta sem malesuada magna\nmollis euismod. Etiam porta sem malesuada magna mollis euismod.\nDonec sed odio dui. Sed posuere consectetur est at lobortis."
    }
  ]
}) }}

Venenatis Condimentum

Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      Venenatis Condimentum
    </h1>
  </legend>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-long-text" name="example" type="radio" value="nullam">
      <label class="nhsuk-label nhsuk-radios__label" for="with-long-text">
        Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo
        quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
        Maecenas faucibus mollis interdum. Donec id elit non mi porta gravida
        at eget metus.
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-long-text-2" name="example" type="radio" value="aenean">
      <label class="nhsuk-label nhsuk-radios__label" for="with-long-text-2">
        Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis
        vestibulum. Donec sed odio dui. Duis mollis, est non commodo luctus,
        nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis
        natoque penatibus et magnis dis parturient montes, nascetur ridiculus
        mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam
        venenatis vestibulum. Cras mattis consectetur purus sit amet
        fermentum.
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="with-long-text-3" name="example" type="radio" value="fusce">
      <label class="nhsuk-label nhsuk-radios__label" for="with-long-text-3">
        Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum
        nibh, ut fermentum massa justo sit amet risus. Etiam porta sem
        malesuada magna mollis euismod. Praesent commodo cursus magna, vel
        scelerisque nisl consectetur et. Etiam porta sem malesuada magna
        mollis euismod. Etiam porta sem malesuada magna mollis euismod.
        Donec sed odio dui. Sed posuere consectetur est at lobortis.
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "Venenatis Condimentum",
      size: "m"
    }
  },
  idPrefix: "with-long-text",
  name: "example",
  items: [
    {
      value: "nullam",
      text: "Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo\nquam. Pellentesque ornare sem lacinia quam venenatis vestibulum.\nMaecenas faucibus mollis interdum. Donec id elit non mi porta gravida\nat eget metus."
    },
    {
      value: "aenean",
      text: "Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis\nvestibulum. Donec sed odio dui. Duis mollis, est non commodo luctus,\nnisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis\nnatoque penatibus et magnis dis parturient montes, nascetur ridiculus\nmus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam\nvenenatis vestibulum. Cras mattis consectetur purus sit amet\nfermentum."
    },
    {
      value: "fusce",
      text: "Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum\nnibh, ut fermentum massa justo sit amet risus. Etiam porta sem\nmalesuada magna mollis euismod. Praesent commodo cursus magna, vel\nscelerisque nisl consectetur et. Etiam porta sem malesuada magna\nmollis euismod. Etiam porta sem malesuada magna mollis euismod.\nDonec sed odio dui. Sed posuere consectetur est at lobortis."
    }
  ],
  small: true
}) }}

How do you want to be contacted about this?

Select 1 option
How do you want to be contacted about this?
Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-nested-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-nested-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-nested" name="example-outer" type="radio" value="no-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-nested">
        No conditional
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-nested-2" name="example-outer" type="radio" value="nested" data-aria-controls="conditional-conditional-nested-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-nested-2">
        Nested conditional
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-nested-2">
<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="example-inner-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--s">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-hint" id="example-inner-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-inner" name="example-inner" type="radio" value="email" data-aria-controls="conditional-example-inner">
      <label class="nhsuk-label nhsuk-radios__label" for="example-inner">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-example-inner">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-inner-2" name="example-inner" type="radio" value="phone" data-aria-controls="conditional-example-inner-2">
      <label class="nhsuk-label nhsuk-radios__label" for="example-inner-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-example-inner-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="example-inner-3" name="example-inner" type="radio" value="text" data-aria-controls="conditional-example-inner-3">
      <label class="nhsuk-label nhsuk-radios__label" for="example-inner-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-example-inner-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional-nested",
  name: "example-outer",
  items: [
    {
      value: "no-conditional",
      text: "No conditional"
    },
    {
      value: "nested",
      text: "Nested conditional",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <fieldset class="nhsuk-fieldset" aria-describedby="example-inner-hint">\n  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--s">\n    How do you want to be contacted about this?\n  </legend>\n  <div class="nhsuk-hint" id="example-inner-hint">\n    Select 1 option\n  </div>\n  <div class="nhsuk-radios" data-module="nhsuk-radios">\n    <div class="nhsuk-radios__item">\n      <input class="nhsuk-radios__input" id="example-inner" name="example-inner" type="radio" value="email" data-aria-controls="conditional-example-inner">\n      <label class="nhsuk-label nhsuk-radios__label" for="example-inner">\n        Email\n      </label>\n    </div>\n    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-example-inner">\n<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n    </div>\n    <div class="nhsuk-radios__item">\n      <input class="nhsuk-radios__input" id="example-inner-2" name="example-inner" type="radio" value="phone" data-aria-controls="conditional-example-inner-2">\n      <label class="nhsuk-label nhsuk-radios__label" for="example-inner-2">\n        Phone\n      </label>\n    </div>\n    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-example-inner-2">\n<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n    </div>\n    <div class="nhsuk-radios__item">\n      <input class="nhsuk-radios__input" id="example-inner-3" name="example-inner" type="radio" value="text" data-aria-controls="conditional-example-inner-3">\n      <label class="nhsuk-label nhsuk-radios__label" for="example-inner-3">\n        Text message\n      </label>\n    </div>\n    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-example-inner-3">\n<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n    </div>\n  </div>\n</fieldset>\n</div>\n'
      }
    }
  ]
}) }}
Code

Markup

<div class="nhsuk-form-group">
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-fieldset" name="colours" type="radio" value="red">
      <label class="nhsuk-label nhsuk-radios__label" for="without-fieldset">
        Red
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-fieldset-2" name="colours" type="radio" value="green">
      <label class="nhsuk-label nhsuk-radios__label" for="without-fieldset-2">
        Green
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-fieldset-3" name="colours" type="radio" value="blue">
      <label class="nhsuk-label nhsuk-radios__label" for="without-fieldset-3">
        Blue
      </label>
    </div>
  </div>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: null,
  idPrefix: "without-fieldset",
  name: "colours",
  items: [
    {
      value: "red",
      text: "Red"
    },
    {
      value: "green",
      text: "Green"
    },
    {
      value: "blue",
      text: "Blue"
    }
  ]
}) }}
Code

Markup

<div class="nhsuk-form-group">
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-fieldset" name="colours" type="radio" value="red">
      <label class="nhsuk-label nhsuk-radios__label" for="without-fieldset">
        Red
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-fieldset-2" name="colours" type="radio" value="green">
      <label class="nhsuk-label nhsuk-radios__label" for="without-fieldset-2">
        Green
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-fieldset-3" name="colours" type="radio" value="blue">
      <label class="nhsuk-label nhsuk-radios__label" for="without-fieldset-3">
        Blue
      </label>
    </div>
  </div>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: null,
  idPrefix: "without-fieldset",
  name: "colours",
  items: [
    {
      value: "red",
      text: "Red"
    },
    {
      value: "green",
      text: "Green"
    },
    {
      value: "blue",
      text: "Blue"
    }
  ],
  small: true
}) }}
How do you want to be contacted about this?
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset">
  <legend class="nhsuk-fieldset__legend">
    How do you want to be contacted about this?
  </legend>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-heading" name="example" type="radio" value="email">
      <label class="nhsuk-label nhsuk-radios__label" for="without-heading">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-heading-2" name="example" type="radio" value="phone">
      <label class="nhsuk-label nhsuk-radios__label" for="without-heading-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="without-heading-3" name="example" type="radio" value="text">
      <label class="nhsuk-label nhsuk-radios__label" for="without-heading-3">
        Text message
      </label>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: "How do you want to be contacted about this?"
  },
  idPrefix: "without-heading",
  name: "example",
  items: [
    {
      value: "email",
      text: "Email"
    },
    {
      value: "phone",
      text: "Phone"
    },
    {
      value: "text",
      text: "Text message"
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" checked data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "l"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional",
  name: "example",
  value: "email",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ]
}) }}

How do you want to be contacted about this?

Select 1 option
Code

Markup

<div class="nhsuk-form-group">
  <fieldset class="nhsuk-fieldset" aria-describedby="conditional-hint">
  <legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--m">
    <h1 class="nhsuk-fieldset__heading">
      How do you want to be contacted about this?
    </h1>
  </legend>
  <div class="nhsuk-hint" id="conditional-hint">
    Select 1 option
  </div>
  <div class="nhsuk-radios nhsuk-radios--small" data-module="nhsuk-radios">
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional" name="example" type="radio" value="email" checked data-aria-controls="conditional-conditional">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional">
        Email
      </label>
    </div>
    <div class="nhsuk-radios__conditional" id="conditional-conditional">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-email">
    Email address
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-2" name="example" type="radio" value="phone" data-aria-controls="conditional-conditional-2">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-2">
        Phone
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-2">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-phone">
    Phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">
</div>
    </div>
    <div class="nhsuk-radios__item">
      <input class="nhsuk-radios__input" id="conditional-3" name="example" type="radio" value="text" data-aria-controls="conditional-conditional-3">
      <label class="nhsuk-label nhsuk-radios__label" for="conditional-3">
        Text message
      </label>
    </div>
    <div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-conditional-3">
<div class="nhsuk-form-group">
  <label class="nhsuk-label" for="contact-by-text">
    Mobile phone number
  </label>
  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">
</div>
    </div>
  </div>
</fieldset>
</div>

Macro

{% from "radios/macro.njk" import radios -%}

{{ radios({
  fieldset: {
    legend: {
      heading: "How do you want to be contacted about this?",
      size: "m"
    }
  },
  hint: {
    text: "Select 1 option"
  },
  idPrefix: "conditional",
  name: "example",
  value: "email",
  items: [
    {
      value: "email",
      text: "Email",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-email">\n    Email address\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-email" name="contact-by-email" type="text" spellcheck="false">\n</div>\n'
      }
    },
    {
      value: "phone",
      text: "Phone",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-phone">\n    Phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-phone" name="contact-by-phone" type="tel">\n</div>\n'
      }
    },
    {
      value: "text",
      text: "Text message",
      conditional: {
        html: '<div class="nhsuk-form-group">\n  <label class="nhsuk-label" for="contact-by-text">\n    Mobile phone number\n  </label>\n  <input class="nhsuk-input nhsuk-u-width-two-thirds" id="contact-by-text" name="contact-by-text" type="tel">\n</div>\n'
      }
    }
  ],
  small: true
}) }}