Skip to main content

Radios examples

  • # default

    Have you changed your name?
    {
      "name": "example-default",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-default",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with hint

    Have you changed your name?
    This includes changing your last name or spelling your name differently.
    {
      "name": "example-with-hint",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-with-hint",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # inline

    Have you changed your name?
    This includes changing your last name or spelling your name differently.
    {
      "idPrefix": "example",
      "classes": "govuk-radios--inline",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No",
          "checked": true
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "example",
      "classes": "govuk-radios--inline",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No",
          "checked": true
        }
      ]
    }) }}
            
  • # with legend as page heading

    Which part of the Housing Act was your licence issued under?

    Select one of the options below.
    {
      "idPrefix": "housing-act",
      "name": "housing-act",
      "fieldset": {
        "legend": {
          "text": "Which part of the Housing Act was your licence issued under?",
          "classes": "govuk-fieldset__legend--l",
          "isPageHeading": true
        }
      },
      "hint": {
        "text": "Select one of the options below."
      },
      "items": [
        {
          "value": "part-2",
          "html": "<span class=\"govuk-heading-s govuk-!-margin-bottom-1\">Part 2 of the Housing Act 2004</span> For properties that are 3 or more stories high and occupied by 5 or more people"
        },
        {
          "value": "part-3",
          "html": "<span class=\"govuk-heading-s govuk-!-margin-bottom-1\">Part 3 of the Housing Act 2004</span> For properties that are within a geographical area defined by a local council"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "housing-act",
      "name": "housing-act",
      "fieldset": {
        "legend": {
          "text": "Which part of the Housing Act was your licence issued under?",
          "classes": "govuk-fieldset__legend--l",
          "isPageHeading": true
        }
      },
      "hint": {
        "text": "Select one of the options below."
      },
      "items": [
        {
          "value": "part-2",
          "html": "<span class=\"govuk-heading-s govuk-!-margin-bottom-1\">Part 2 of the Housing Act 2004</span> For properties that are 3 or more stories high and occupied by 5 or more people"
        },
        {
          "value": "part-3",
          "html": "<span class=\"govuk-heading-s govuk-!-margin-bottom-1\">Part 3 of the Housing Act 2004</span> For properties that are within a geographical area defined by a local council"
        }
      ]
    }) }}
            
  • # with a divider

    How do you want to sign in?
    or
    {
      "idPrefix": "example-divider",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?"
        }
      },
      "items": [
        {
          "value": "government-gateway",
          "text": "Use Government Gateway"
        },
        {
          "value": "govuk-verify",
          "text": "Use GOV.UK Verify"
        },
        {
          "divider": "or"
        },
        {
          "value": "create-account",
          "text": "Create an account"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "example-divider",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?"
        }
      },
      "items": [
        {
          "value": "government-gateway",
          "text": "Use Government Gateway"
        },
        {
          "value": "govuk-verify",
          "text": "Use GOV.UK Verify"
        },
        {
          "divider": "or"
        },
        {
          "value": "create-account",
          "text": "Create an account"
        }
      ]
    }) }}
            
  • # with hints on items

    How do you want to sign in?

    You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before.
    You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity.
    {
      "idPrefix": "gov",
      "name": "gov",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?",
          "classes": "govuk-fieldset__legend--l",
          "isPageHeading": true
        }
      },
      "items": [
        {
          "value": "gateway",
          "text": "Sign in with Government Gateway",
          "id": "gateway",
          "hint": {
            "text": "You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before."
          }
        },
        {
          "value": "verify",
          "text": "Sign in with GOV.UK Verify",
          "id": "verify",
          "hint": {
            "text": "You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity."
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "gov",
      "name": "gov",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?",
          "classes": "govuk-fieldset__legend--l",
          "isPageHeading": true
        }
      },
      "items": [
        {
          "value": "gateway",
          "text": "Sign in with Government Gateway",
          "id": "gateway",
          "hint": {
            "text": "You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before."
          }
        },
        {
          "value": "verify",
          "text": "Sign in with GOV.UK Verify",
          "id": "verify",
          "hint": {
            "text": "You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity."
          }
        }
      ]
    }) }}
            
  • # without fieldset

    {
      "name": "colours",
      "items": [
        {
          "value": "red",
          "text": "Red"
        },
        {
          "value": "green",
          "text": "Green"
        },
        {
          "value": "blue",
          "text": "Blue"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "colours",
      "items": [
        {
          "value": "red",
          "text": "Red"
        },
        {
          "value": "green",
          "text": "Green"
        },
        {
          "value": "blue",
          "text": "Blue"
        }
      ]
    }) }}
            
  • # with fieldset and error message

    Have you changed your name?

    Error: Please select an option

    {
      "idPrefix": "example",
      "name": "example",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No",
          "checked": true
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "example",
      "name": "example",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No",
          "checked": true
        }
      ]
    }) }}
            
  • # with very long option text

    Maecenas faucibus mollis interdum?
    Nullam id dolor id nibh ultricies vehicula ut id elit.

    Error: Lorem ipsum dolor sit amet, consectetur adipiscing elit.

    {
      "name": "waste",
      "hint": {
        "text": "Nullam id dolor id nibh ultricies vehicula ut id elit."
      },
      "errorMessage": {
        "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
      },
      "fieldset": {
        "legend": {
          "text": "Maecenas faucibus mollis interdum?"
        }
      },
      "items": [
        {
          "value": "nullam",
          "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."
        },
        {
          "value": "aenean",
          "text": "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."
        },
        {
          "value": "fusce",
          "text": "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."
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "waste",
      "hint": {
        "text": "Nullam id dolor id nibh ultricies vehicula ut id elit."
      },
      "errorMessage": {
        "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
      },
      "fieldset": {
        "legend": {
          "text": "Maecenas faucibus mollis interdum?"
        }
      },
      "items": [
        {
          "value": "nullam",
          "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."
        },
        {
          "value": "aenean",
          "text": "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."
        },
        {
          "value": "fusce",
          "text": "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."
        }
      ]
    }) }}
            
  • # with conditional items

    How do you want to be contacted?
    {
      "idPrefix": "how-contacted",
      "name": "how-contacted",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email address</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted",
      "name": "how-contacted",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email address</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }) }}
            
  • # with conditional item checked

    How do you want to be contacted?
    {
      "idPrefix": "how-contacted-checked",
      "name": "how-contacted-checked",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "checked": true,
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-checked",
      "name": "how-contacted-checked",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "checked": true,
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }) }}
            
  • # with optional form-group classes showing group error

    How do you want to be contacted?
    Problem with input
    {
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-form-group--error"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email address</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "checked": true,
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<span id=\"contact-phone-error\" class=\"govuk-error-message\">Problem with input</span>\n<input class=\"govuk-input govuk-input--error govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\" aria-describedby=\"contact-phone-error\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-form-group--error"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email address</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "checked": true,
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<span id=\"contact-phone-error\" class=\"govuk-error-message\">Problem with input</span>\n<input class=\"govuk-input govuk-input--error govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\" aria-describedby=\"contact-phone-error\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }) }}
            
  • # small

    How do you want to be contacted?
    {
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email"
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email"
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }) }}
            
  • # small with long text

    Venenatis Condimentum
    {
      "idPrefix": "foo",
      "name": "foo",
      "classes": "govuk-radios--small",
      "fieldset": {
        "legend": {
          "text": "Venenatis Condimentum"
        }
      },
      "items": [
        {
          "value": "nullam",
          "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."
        },
        {
          "value": "aenean",
          "text": "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."
        },
        {
          "value": "fusce",
          "text": "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."
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "foo",
      "name": "foo",
      "classes": "govuk-radios--small",
      "fieldset": {
        "legend": {
          "text": "Venenatis Condimentum"
        }
      },
      "items": [
        {
          "value": "nullam",
          "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."
        },
        {
          "value": "aenean",
          "text": "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."
        },
        {
          "value": "fusce",
          "text": "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."
        }
      ]
    }) }}
            
  • # small with error

    How do you want to be contacted?

    Error: Select a thing

    {
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "errorMessage": {
        "text": "Select a thing"
      },
      "items": [
        {
          "value": "email",
          "text": "Email"
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "errorMessage": {
        "text": "Select a thing"
      },
      "items": [
        {
          "value": "email",
          "text": "Email"
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }) }}
            
  • # small with hint

    How do you want to be contacted?
    Hint for email address
    {
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "hint": {
            "text": "Hint for email address"
          }
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "hint": {
            "text": "Hint for email address"
          }
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }) }}
            
  • # small with conditional reveal

    How do you want to be contacted?
    {
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Foo</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-2",
      "name": "how-contacted-2",
      "formGroup": {
        "classes": "govuk-radios--small"
      },
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Foo</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone"
        },
        {
          "value": "text",
          "text": "Text message"
        }
      ]
    }) }}
            
  • # small inline

    Sort by
    {
      "idPrefix": "sort",
      "classes": "govuk-radios--small govuk-radios--inline",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "Sort by"
        }
      },
      "items": [
        {
          "value": "relevance",
          "text": "relevance"
        },
        {
          "value": "title",
          "text": "title"
        },
        {
          "value": "created",
          "text": "created"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "sort",
      "classes": "govuk-radios--small govuk-radios--inline",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "Sort by"
        }
      },
      "items": [
        {
          "value": "relevance",
          "text": "relevance"
        },
        {
          "value": "title",
          "text": "title"
        },
        {
          "value": "created",
          "text": "created"
        }
      ]
    }) }}
            
  • # small with a divider

    How do you want to sign in?
    or
    {
      "idPrefix": "example-small-divider",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?"
        }
      },
      "classes": "govuk-radios--small",
      "items": [
        {
          "value": "government-gateway",
          "text": "Use Government Gateway"
        },
        {
          "value": "govuk-verify",
          "text": "Use GOV.UK Verify"
        },
        {
          "divider": "or"
        },
        {
          "value": "create-account",
          "text": "Create an account"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "example-small-divider",
      "name": "example",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?"
        }
      },
      "classes": "govuk-radios--small",
      "items": [
        {
          "value": "government-gateway",
          "text": "Use Government Gateway"
        },
        {
          "value": "govuk-verify",
          "text": "Use GOV.UK Verify"
        },
        {
          "divider": "or"
        },
        {
          "value": "create-account",
          "text": "Create an account"
        }
      ]
    }) }}
            
  • # with idPrefix

    {
      "name": "example-radio",
      "idPrefix": "example-id-prefix",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-radio",
      "idPrefix": "example-id-prefix",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # minimal items and name

    {
      "name": "example-name",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-name",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with falsy items

    {
      "name": "example-name",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        null,
        false,
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-name",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        null,
        false,
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # fieldset with describedBy

    Which option?
    {
      "name": "example-name",
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Which option?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-name",
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Which option?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # attributes

    {
      "name": "example-name",
      "attributes": {
        "data-attribute": "value",
        "data-second-attribute": "second-value"
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-name",
      "attributes": {
        "data-attribute": "value",
        "data-second-attribute": "second-value"
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # items with attributes

    {
      "name": "example-name",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "attributes": {
            "data-attribute": "ABC",
            "data-second-attribute": "DEF"
          }
        },
        {
          "value": "no",
          "text": "No",
          "attributes": {
            "data-attribute": "GHI",
            "data-second-attribute": "JKL"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-name",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "attributes": {
            "data-attribute": "ABC",
            "data-second-attribute": "DEF"
          }
        },
        {
          "value": "no",
          "text": "No",
          "attributes": {
            "data-attribute": "GHI",
            "data-second-attribute": "JKL"
          }
        }
      ]
    }) }}
            
  • # with empty conditional

    {
      "name": "example-conditional",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "conditional": {
            "html": false
          }
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-conditional",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "conditional": {
            "html": false
          }
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # label with classes

    {
      "name": "example-label-classes",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "label": {
            "classes": "bold"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-label-classes",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "label": {
            "classes": "bold"
          }
        }
      ]
    }) }}
            
  • # with hints on parent and items

    Have you changed your name?
    This includes changing your last name or spelling your name differently.
    Hint for yes option here
    Hint for no option here
    {
      "name": "example-multiple-hints",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "hint": {
            "text": "Hint for yes option here"
          }
        },
        {
          "value": "no",
          "text": "No",
          "hint": {
            "text": "Hint for no option here"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-multiple-hints",
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "hint": {
            "text": "Hint for yes option here"
          }
        },
        {
          "value": "no",
          "text": "No",
          "hint": {
            "text": "Hint for no option here"
          }
        }
      ]
    }) }}
            
  • # with describedBy and hint

    Have you changed your name?
    This includes changing your last name or spelling your name differently.
    {
      "name": "example-hint-describedby",
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-hint-describedby",
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with error message

    Error: Please select an option

    {
      "name": "example-error-message",
      "errorMessage": {
        "text": "Please select an option"
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-error-message",
      "errorMessage": {
        "text": "Please select an option"
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with error message and idPrefix

    Error: Please select an option

    {
      "name": "example-error-message",
      "idPrefix": "id-prefix",
      "errorMessage": {
        "text": "Please select an option"
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-error-message",
      "idPrefix": "id-prefix",
      "errorMessage": {
        "text": "Please select an option"
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with hint and error message

    Have you changed your name?
    This includes changing your last name or spelling your name differently.

    Error: Please select an option

    {
      "name": "example-error-message-hint",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-error-message-hint",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with hint, error message and describedBy

    Have you changed your name?
    This includes changing your last name or spelling your name differently.

    Error: Please select an option

    {
      "name": "example-error-message-hint",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-error-message-hint",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # label with attributes

    {
      "name": "with-label-attributes",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "label": {
            "attributes": {
              "data-attribute": "value",
              "data-second-attribute": "second-value"
            }
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "with-label-attributes",
      "items": [
        {
          "value": "yes",
          "text": "Yes",
          "label": {
            "attributes": {
              "data-attribute": "value",
              "data-second-attribute": "second-value"
            }
          }
        }
      ]
    }) }}
            
  • # fieldset params

    Have you changed your name?
    This includes changing your last name or spelling your name differently.
    {
      "name": "example-fieldset-params",
      "fieldset": {
        "classes": "app-fieldset--custom-modifier",
        "legend": {
          "text": "Have you changed your name?"
        },
        "attributes": {
          "data-attribute": "value",
          "data-second-attribute": "second-value"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-fieldset-params",
      "fieldset": {
        "classes": "app-fieldset--custom-modifier",
        "legend": {
          "text": "Have you changed your name?"
        },
        "attributes": {
          "data-attribute": "value",
          "data-second-attribute": "second-value"
        }
      },
      "hint": {
        "text": "This includes changing your last name or spelling your name differently."
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # fieldset with html

    Have you changed your name?
    {
      "name": "with-fieldset-html",
      "fieldset": {
        "legend": {
          "html": "Have <b>you</b> changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "with-fieldset-html",
      "fieldset": {
        "legend": {
          "html": "Have <b>you</b> changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ]
    }) }}
            
  • # with fieldset, error message and describedBy

    Have you changed your name?

    Error: Please select an option

    {
      "idPrefix": "example",
      "name": "example",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No",
          "checked": true
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "example",
      "name": "example",
      "errorMessage": {
        "text": "Please select an option"
      },
      "fieldset": {
        "describedBy": "test-target-element",
        "legend": {
          "text": "Have you changed your name?"
        }
      },
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No",
          "checked": true
        }
      ]
    }) }}
            
  • # item checked overrides value

    {
      "name": "colors",
      "items": [
        {
          "value": "red",
          "text": "Red"
        },
        {
          "value": "green",
          "text": "Green",
          "checked": false
        },
        {
          "value": "blue",
          "text": "Blue"
        }
      ],
      "value": "green"
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "colors",
      "items": [
        {
          "value": "red",
          "text": "Red"
        },
        {
          "value": "green",
          "text": "Green",
          "checked": false
        },
        {
          "value": "blue",
          "text": "Blue"
        }
      ],
      "value": "green"
    }) }}
            
  • # textarea in conditional

    Test
    {
      "name": "conditional",
      "fieldset": {
        "legend": {
          "text": "Test"
        }
      },
      "items": [
        {
          "value": "other",
          "text": "Other",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"conditional-textarea\">textarea</label>\n<textarea class=\"govuk-textarea\" name=\"conditional-textarea\" id=\"conditional-textarea\">\ntest\n</textarea>\n"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "conditional",
      "fieldset": {
        "legend": {
          "text": "Test"
        }
      },
      "items": [
        {
          "value": "other",
          "text": "Other",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"conditional-textarea\">textarea</label>\n<textarea class=\"govuk-textarea\" name=\"conditional-textarea\" id=\"conditional-textarea\">\ntest\n</textarea>\n"
          }
        }
      ]
    }) }}
            
  • # with disabled

    How do you want to sign in?

    You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before.
    You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity.
    {
      "idPrefix": "gov",
      "name": "gov",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?",
          "classes": "govuk-fieldset__legend--l",
          "isPageHeading": true
        }
      },
      "items": [
        {
          "value": "gateway",
          "text": "Sign in with Government Gateway",
          "id": "gateway",
          "hint": {
            "text": "You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before."
          }
        },
        {
          "value": "verify",
          "text": "Sign in with GOV.UK Verify",
          "id": "verify",
          "hint": {
            "text": "You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity."
          },
          "disabled": true
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "gov",
      "name": "gov",
      "fieldset": {
        "legend": {
          "text": "How do you want to sign in?",
          "classes": "govuk-fieldset__legend--l",
          "isPageHeading": true
        }
      },
      "items": [
        {
          "value": "gateway",
          "text": "Sign in with Government Gateway",
          "id": "gateway",
          "hint": {
            "text": "You’ll have a user ID if you’ve registered for Self Assessment or filed a tax return online before."
          }
        },
        {
          "value": "verify",
          "text": "Sign in with GOV.UK Verify",
          "id": "verify",
          "hint": {
            "text": "You’ll have an account if you’ve already proved your identity with either Barclays, CitizenSafe, Digidentity, Experian, Post Office, Royal Mail or SecureIdentity."
          },
          "disabled": true
        }
      ]
    }) }}
            
  • # prechecked using value

    {
      "name": "example-default",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ],
      "value": "no"
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "name": "example-default",
      "items": [
        {
          "value": "yes",
          "text": "Yes"
        },
        {
          "value": "no",
          "text": "No"
        }
      ],
      "value": "no"
    }) }}
            
  • # with conditional items with special characters

    How do you want to be contacted?
    {
      "idPrefix": "user.profile[contact-prefs]",
      "name": "contact-prefs",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email address</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "user.profile[contact-prefs]",
      "name": "contact-prefs",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email address</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ]
    }) }}
            
  • # with conditional items and pre-checked value

    How do you want to be contacted?
    {
      "idPrefix": "how-contacted-checked",
      "name": "how-contacted-checked",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ],
      "value": "text"
    }
    
    {% from "govuk/components/radios/macro.njk" import govukRadios %}
    
    {{ govukRadios({
      "idPrefix": "how-contacted-checked",
      "name": "how-contacted-checked",
      "fieldset": {
        "legend": {
          "text": "How do you want to be contacted?"
        }
      },
      "items": [
        {
          "value": "email",
          "text": "Email",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"context-email\">Email</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"context-email\" type=\"text\" id=\"context-email\">\n"
          }
        },
        {
          "value": "phone",
          "text": "Phone",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-phone\">Phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-phone\" type=\"text\" id=\"contact-phone\">\n"
          }
        },
        {
          "value": "text",
          "text": "Text message",
          "conditional": {
            "html": "<label class=\"govuk-label\" for=\"contact-text-message\">Mobile phone number</label>\n<input class=\"govuk-input govuk-!-width-one-third\" name=\"contact-text-message\" type=\"text\" id=\"contact-text-message\">\n"
          }
        }
      ],
      "value": "text"
    }) }}