Skip to main content Skip to list of components
Service phase: 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. Component 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.

The label for the radios field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the radios title (xl, l, m or s).

id string

Required.

A unique ID for the radios component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

error object

If set, the details of any errors.

See macro options for error.

items array

Required.

See macro options for items.

selected string
small boolean

If true, show smaller radios.

inline boolean

If true, show the radios inline rather than vertical.

formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes object

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.

The error text to display.

Options for items
Name Type Description
text string

Required.

value string

Required.

The form field value.

{% 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"
    }
  ]
}) }}
Phase
Ready for production
Tested without CSS
Yes
Passed DAC audit
Not yet audied
Analytics integrated
Yes
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>
  </fieldset>
</div>

Nunjucks

Nunjucks options
Primary options
Name Type Description
label string

Required.

The label for the radios field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the radios title (xl, l, m or s).

id string

Required.

A unique ID for the radios component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

error object

If set, the details of any errors.

See macro options for error.

items array

Required.

See macro options for items.

selected string
small boolean

If true, show smaller radios.

inline boolean

If true, show the radios inline rather than vertical.

formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes object

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.

The error text to display.

Options for items
Name Type Description
text string

Required.

value string

Required.

The form field value.

{% 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"
    }
  ],
  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.

The label for the radios field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the radios title (xl, l, m or s).

id string

Required.

A unique ID for the radios component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

error object

If set, the details of any errors.

See macro options for error.

items array

Required.

See macro options for items.

selected string
small boolean

If true, show smaller radios.

inline boolean

If true, show the radios inline rather than vertical.

formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes object

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.

The error text to display.

Options for items
Name Type Description
text string

Required.

value string

Required.

The form field value.

{% 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.

The label for the radios field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the radios title (xl, l, m or s).

id string

Required.

A unique ID for the radios component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

error object

If set, the details of any errors.

See macro options for error.

items array

Required.

See macro options for items.

selected string
small boolean

If true, show smaller radios.

inline boolean

If true, show the radios inline rather than vertical.

formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes object

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.

The error text to display.

Options for items
Name Type Description
text string

Required.

value string

Required.

The form field value.

{% 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.

The label for the radios field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the radios title (xl, l, m or s).

id string

Required.

A unique ID for the radios component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

error object

If set, the details of any errors.

See macro options for error.

items array

Required.

See macro options for items.

selected string
small boolean

If true, show smaller radios.

inline boolean

If true, show the radios inline rather than vertical.

formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes object

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.

The error text to display.

Options for items
Name Type Description
text string

Required.

value string

Required.

The form field value.

{% 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.

The label for the radios field.

headingLevel number

Required.

The heading level which represents an element from <h1> through to <h6>.

headingSize string

The physical size of the radios title (xl, l, m or s).

id string

Required.

A unique ID for the radios component.

name string

Required.

The name of the form field.

hint string

An optional hint to display above the form field.

error object

If set, the details of any errors.

See macro options for error.

items array

Required.

See macro options for items.

selected string
small boolean

If true, show smaller radios.

inline boolean

If true, show the radios inline rather than vertical.

formGroupClasses string

Classes to add to the radios form group.

formGroupAttributes object

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.

The error text to display.

Options for items
Name Type Description
text string

Required.

value string

Required.

The form field value.

{% 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