Skip to main content Skip to list of components
Beta

This is a new service – give us your feedback to help improve it.

Components

Radios

Radios allow users to select a single options for a form field.

Contents

  1. Status
  2. Small
  3. Preselected
  4. Hint
  5. Error
  6. Inline
Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Type
      </h4>
    </legend>
    <div class="tna-radios" id="type">
      <div class="tna-radios__item">
        <input type="radio" id="type-audio" value="audio" name="type">
        <label for="type-audio" class="tna-radios__item-label">
          Audio
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-image" value="image" name="type">
        <label for="type-image" class="tna-radios__item-label">
          Image
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-video" value="video" name="type">
        <label for="type-video" class="tna-radios__item-label">
          Video
        </label>
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
error object

See error.

items array

Required.

See items.

selected string
small boolean
inline boolean
formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes string

HTML attributes (for example data attributes) to add to the radios form group.

classes string

Classes to add to the radio elements.

attributes object

HTML attributes (for example data attributes) to add to the radio elements.

Options for error
Name Type Description
text string

Required.

Options for items
Name Type Description
text string

Required.

value string

Required.

{% from "nationalarchives/components/radios/macro.njk" import tnaRadios %}

{{ tnaRadios({
  label: "Type",
  headingLevel: 4,
  headingSize: "m",
  id: "type",
  name: "type",
  items: [
    {
      text: "Audio",
      value: "audio"
    },
    {
      text: "Image",
      value: "image"
    },
    {
      text: "Video",
      value: "video"
    }
  ]
}) }}
Status
In development
Tested without CSS
Yes
WCAG 2.2 AA compliant
In development
Analytics integrated
In development
Documentation complete
No
Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Type
      </h4>
    </legend>
    <div class="tna-radios tna-radios--small" id="type">
      <div class="tna-radios__item">
        <input type="radio" id="type-ADM" value="ADM" name="type">
        <label for="type-ADM" class="tna-radios__item-label">
          Admiralty, Navy, Royal Marines, and Coastguard
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-AIR" value="AIR" name="type">
        <label for="type-AIR" class="tna-radios__item-label">
          Air Ministry and Royal Air Force records
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-BT" value="BT" name="type">
        <label for="type-BT" class="tna-radios__item-label">
          Board of Trade and successors
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-C" value="C" name="type">
        <label for="type-C" class="tna-radios__item-label">
          Chancery, the Wardrobe, Royal Household, Exchequer and various commissions
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-CO" value="CO" name="type">
        <label for="type-CO" class="tna-radios__item-label">
          Colonial Office, Commonwealth and Foreign and Commonwealth Offices
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-E" value="E" name="type">
        <label for="type-E" class="tna-radios__item-label">
          Exchequer, Office of First Fruits and Tenths, and the Court of Augmentations
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-FO" value="FO" name="type">
        <label for="type-FO" class="tna-radios__item-label">
          Foreign Office
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-HO" value="HO" name="type">
        <label for="type-HO" class="tna-radios__item-label">
          Home Office
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-PROB" value="PROB" name="type">
        <label for="type-PROB" class="tna-radios__item-label">
          Prerogative Court of Canterbury
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-WO" value="WO" name="type">
        <label for="type-WO" class="tna-radios__item-label">
          War Office, Armed Forces, Judge Advocate General, and related bodies
        </label>
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
error object

See error.

items array

Required.

See items.

selected string
small boolean
inline boolean
formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes string

HTML attributes (for example data attributes) to add to the radios form group.

classes string

Classes to add to the radio elements.

attributes object

HTML attributes (for example data attributes) to add to the radio elements.

Options for error
Name Type Description
text string

Required.

Options for items
Name Type Description
text string

Required.

value string

Required.

{% from "nationalarchives/components/radios/macro.njk" import tnaRadios %}

{{ tnaRadios({
  label: "Type",
  headingLevel: 4,
  headingSize: "m",
  id: "type",
  name: "type",
  items: [
    {
      text: "Admiralty, Navy, Royal Marines, and Coastguard",
      value: "ADM"
    },
    {
      text: "Air Ministry and Royal Air Force records",
      value: "AIR"
    },
    {
      text: "Board of Trade and successors",
      value: "BT"
    },
    {
      text: "Chancery, the Wardrobe, Royal Household, Exchequer and various commissions",
      value: "C"
    },
    {
      text: "Colonial Office, Commonwealth and Foreign and Commonwealth Offices",
      value: "CO"
    },
    {
      text: "Exchequer, Office of First Fruits and Tenths, and the Court of Augmentations",
      value: "E"
    },
    {
      text: "Foreign Office",
      value: "FO"
    },
    {
      text: "Home Office",
      value: "HO"
    },
    {
      text: "Prerogative Court of Canterbury",
      value: "PROB"
    },
    {
      text: "War Office, Armed Forces, Judge Advocate General, and related bodies",
      value: "WO"
    }
  ],
  small: true
}) }}
Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Type
      </h4>
    </legend>
    <div class="tna-radios" id="type">
      <div class="tna-radios__item">
        <input type="radio" id="type-audio" value="audio" name="type">
        <label for="type-audio" class="tna-radios__item-label">
          Audio
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-image" value="image" name="type" checked>
        <label for="type-image" class="tna-radios__item-label">
          Image
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-video" value="video" name="type">
        <label for="type-video" class="tna-radios__item-label">
          Video
        </label>
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
error object

See error.

items array

Required.

See items.

selected string
small boolean
inline boolean
formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes string

HTML attributes (for example data attributes) to add to the radios form group.

classes string

Classes to add to the radio elements.

attributes object

HTML attributes (for example data attributes) to add to the radio elements.

Options for error
Name Type Description
text string

Required.

Options for items
Name Type Description
text string

Required.

value string

Required.

{% from "nationalarchives/components/radios/macro.njk" import tnaRadios %}

{{ tnaRadios({
  label: "Type",
  headingLevel: 4,
  headingSize: "m",
  id: "type",
  name: "type",
  items: [
    {
      text: "Audio",
      value: "audio"
    },
    {
      text: "Image",
      value: "image"
    },
    {
      text: "Video",
      value: "video"
    }
  ],
  selected: "image"
}) }}
Open this example in new tab

HTML

<div class="tna-form__group">
  <fieldset class="tna-form__fieldset" aria-describedby="type-hint ">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Type
      </h4>
    </legend>
    <p id="type-hint" class="tna-form__hint">
      You can only select one.
    </p>
    <div class="tna-radios" id="type">
      <div class="tna-radios__item">
        <input type="radio" id="type-audio" value="audio" name="type">
        <label for="type-audio" class="tna-radios__item-label">
          Audio
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-image" value="image" name="type">
        <label for="type-image" class="tna-radios__item-label">
          Image
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-video" value="video" name="type">
        <label for="type-video" class="tna-radios__item-label">
          Video
        </label>
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
error object

See error.

items array

Required.

See items.

selected string
small boolean
inline boolean
formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes string

HTML attributes (for example data attributes) to add to the radios form group.

classes string

Classes to add to the radio elements.

attributes object

HTML attributes (for example data attributes) to add to the radio elements.

Options for error
Name Type Description
text string

Required.

Options for items
Name Type Description
text string

Required.

value string

Required.

{% from "nationalarchives/components/radios/macro.njk" import tnaRadios %}

{{ tnaRadios({
  label: "Type",
  headingLevel: 4,
  headingSize: "m",
  id: "type",
  name: "type",
  hint: "You can only select one.",
  items: [
    {
      text: "Audio",
      value: "audio"
    },
    {
      text: "Image",
      value: "image"
    },
    {
      text: "Video",
      value: "video"
    }
  ]
}) }}
Open this example in new tab

HTML

<div class="tna-form__group tna-form__group--error">
  <fieldset class="tna-form__fieldset" aria-describedby=" type-error">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Type
      </h4>
    </legend>
    <p id="type-error" class="tna-form__error-message">
      <span class="tna-!--visually-hidden">Error:</span> You must select a type
    </p>
    <div class="tna-radios" id="type">
      <div class="tna-radios__item">
        <input type="radio" id="type-audio" value="audio" name="type">
        <label for="type-audio" class="tna-radios__item-label">
          Audio
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-image" value="image" name="type">
        <label for="type-image" class="tna-radios__item-label">
          Image
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-video" value="video" name="type">
        <label for="type-video" class="tna-radios__item-label">
          Video
        </label>
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
error object

See error.

items array

Required.

See items.

selected string
small boolean
inline boolean
formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes string

HTML attributes (for example data attributes) to add to the radios form group.

classes string

Classes to add to the radio elements.

attributes object

HTML attributes (for example data attributes) to add to the radio elements.

Options for error
Name Type Description
text string

Required.

Options for items
Name Type Description
text string

Required.

value string

Required.

{% from "nationalarchives/components/radios/macro.njk" import tnaRadios %}

{{ tnaRadios({
  label: "Type",
  headingLevel: 4,
  headingSize: "m",
  id: "type",
  name: "type",
  error: {
    text: "You must select a type"
  },
  items: [
    {
      text: "Audio",
      value: "audio"
    },
    {
      text: "Image",
      value: "image"
    },
    {
      text: "Video",
      value: "video"
    }
  ]
}) }}
Open this example in new tab

HTML

<div class="tna-form__group tna-form__group--inline">
  <fieldset class="tna-form__fieldset">
    <legend class="tna-form__legend">
      <h4 class="tna-form__heading tna-form__heading--m">
        Type
      </h4>
    </legend>
    <div class="tna-radios tna-radios--small tna-radios--inline" id="type">
      <div class="tna-radios__item">
        <input type="radio" id="type-audio" value="audio" name="type">
        <label for="type-audio" class="tna-radios__item-label">
          Audio
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-image" value="image" name="type">
        <label for="type-image" class="tna-radios__item-label">
          Image
        </label>
      </div>
      <div class="tna-radios__item">
        <input type="radio" id="type-video" value="video" name="type">
        <label for="type-video" class="tna-radios__item-label">
          Video
        </label>
      </div>
    </div>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

headingLevel number

Required.

headingSize string
id string

Required.

name string

Required.

hint string
error object

See error.

items array

Required.

See items.

selected string
small boolean
inline boolean
formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes string

HTML attributes (for example data attributes) to add to the radios form group.

classes string

Classes to add to the radio elements.

attributes object

HTML attributes (for example data attributes) to add to the radio elements.

Options for error
Name Type Description
text string

Required.

Options for items
Name Type Description
text string

Required.

value string

Required.

{% from "nationalarchives/components/radios/macro.njk" import tnaRadios %}

{{ tnaRadios({
  label: "Type",
  headingLevel: 4,
  headingSize: "m",
  id: "type",
  name: "type",
  items: [
    {
      text: "Audio",
      value: "audio"
    },
    {
      text: "Image",
      value: "image"
    },
    {
      text: "Video",
      value: "video"
    }
  ],
  inline: true
}) }}

Back to top