Components Radio buttons Radio buttons present users a choice of options from which they can select only one.
Examples Interact with each example to see how it works.
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import Radios from "@govtnz/ds/build/mustache/Radios.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, P, Radios, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=small": true,
styleSize: true,
id: `nameChangeId5`,
children: `Have you changed your name?`
})}`,
hint: `${Mustache.render(P, {
children: `This includes changing your last name or spelling your name differently.`
})}`,
hintId: `hintId1`,
children: `${Mustache.render(Radios, {
inline: true,
children: `${Mustache.render(RadioBlock, {
label: `Yes`,
id: `anyRadioId`,
value: `true`,
name: `nameChange1`,
labelId: `labelId1`
})}${Mustache.render(RadioBlock, {
label: `No`,
id: `anyRadioId255`,
value: `false`,
name: `nameChange1`,
labelId: `labelId255`
})}`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-js/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-ts/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import Radios from "@govtnz/ds/build/react-js-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import Radios from "@govtnz/ds/build/react-ts-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId1"
>
<c-radios inline>
<radio-block
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<radio-block
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</c-radios>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import Radios from "@govtnz/ds/build/vue-js/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId1"
>
<c-radios inline>
<radio-block
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<radio-block
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</c-radios>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import Radios from "@govtnz/ds/build/vue-ts/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, Radios.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, Radios.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset class="g-fieldsetBlock-fieldset" aria-describedby="hintId1">
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-s" id="nameChangeId5">
Have you changed your name?
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId1">
<p class="g-body">
This includes changing your last name or spelling your name differently.
</p>
</div>
<div>
<div class="g-radios g-radios--inline">
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId"
name="nameChange1"
type="radio"
value="true"
/>
<label class="g-radios__label" for="anyRadioId"> Yes </label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId255"
name="nameChange1"
type="radio"
value="false"
/>
<label class="g-radios__label" for="anyRadioId255"> No </label>
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId1'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'small', 'id':'nameChangeId5', 'children':'Have you changed your name?'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'This includes changing your last name or spelling your name differently.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "Radios.html.twig" with {'inline':'true'} only %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Yes', 'id':'anyRadioId', 'value':'true', 'name':'nameChange1', 'labelId':'labelId1'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'No', 'id':'anyRadioId255', 'value':'false', 'name':'nameChange1', 'labelId':'labelId255'} only %}{% endembed %}{% endblock %}{% endembed %}{% endblock %}{% endembed %}
When to use it Use the radio buttons component when users can only select one option from a list.
When not to use it Do not use the radio buttons component if users might need to select more than one option. Use the checkboxes component instead.
How it works Radio buttons are grouped together in a <fieldset>
with a <legend>
that describes them, as shown in the examples on this page. This is usually a question, like ‘Where do you live?’.
If you are asking just one question per page, you can set the contents of the <legend>
as the page heading.
Always position radio buttons to the left of their labels. This makes them easier to find, especially for users of screen magnifiers.
Unlike with checkboxes, users can only select one option from a list of radio buttons. Do not assume that users will know how many options they can select based on the visual difference between radio buttons and checkboxes alone. If needed, add a hint explaining this, like ‘Select one option’.
Do not pre-select radio button options. Pre-selecting radio button options makes it more likely that users will:
not realise they’ve missed a question submit the wrong answer. Be aware that, once users have selected one option, they have to refresh their browser window to go back to having no option selected. To avoid this, include ‘None of the above’ or ‘I do not know’, if they are valid options.
Order radio button options alphabetically by default.
In some cases, it can be helpful to order them from most to least common. For example, you could order options for ‘Where do you live?’ based on population size.
Another example of pre-selected ordering is listing options chronologically. For example, you could order available appointment times in a day from earliest to latest.
However, using pre-selected ordering could reinforce bias in your service, so use it with caution. If in doubt, order alphabetically.
Stacked radio buttons
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=small": true,
styleSize: true,
id: `whereLiveTitle`,
children: `Where do you live?`
})}`,
children: `${Mustache.render(RadioBlock, {
label: `North Island`,
id: `anyRadioId3334`,
name: `where`,
value: `north`,
labelId: `labelId3`
})}${Mustache.render(RadioBlock, {
label: `South Island`,
id: `anyRadioId42344`,
name: `where`,
value: `south`,
labelId: `labelId4`
})}${Mustache.render(RadioBlock, {
label: `Stewart Island`,
id: `anyRadioId5234`,
name: `where`,
value: `stewart`,
labelId: `labelId5`
})}${Mustache.render(RadioBlock, {
label: `Chatham Islands`,
id: `anyRadioId6234`,
name: `where`,
value: `chatham`,
labelId: `labelId6`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="whereLiveTitle">
Where do you live?
</H1>
}
>
<RadioBlock
label="North Island"
id="anyRadioId3334"
name="where"
value="north"
labelId="labelId3"
/>
<RadioBlock
label="South Island"
id="anyRadioId42344"
name="where"
value="south"
labelId="labelId4"
/>
<RadioBlock
label="Stewart Island"
id="anyRadioId5234"
name="where"
value="stewart"
labelId="labelId5"
/>
<RadioBlock
label="Chatham Islands"
id="anyRadioId6234"
name="where"
value="chatham"
labelId="labelId6"
/>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="whereLiveTitle">
Where do you live?
</H1>
}
>
<RadioBlock
label="North Island"
id="anyRadioId3334"
name="where"
value="north"
labelId="labelId3"
/>
<RadioBlock
label="South Island"
id="anyRadioId42344"
name="where"
value="south"
labelId="labelId4"
/>
<RadioBlock
label="Stewart Island"
id="anyRadioId5234"
name="where"
value="stewart"
labelId="labelId5"
/>
<RadioBlock
label="Chatham Islands"
id="anyRadioId6234"
name="where"
value="chatham"
labelId="labelId6"
/>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="whereLiveTitle">
Where do you live?
</H1>
}
>
<RadioBlock
label="North Island"
id="anyRadioId3334"
name="where"
value="north"
labelId="labelId3"
/>
<RadioBlock
label="South Island"
id="anyRadioId42344"
name="where"
value="south"
labelId="labelId4"
/>
<RadioBlock
label="Stewart Island"
id="anyRadioId5234"
name="where"
value="stewart"
labelId="labelId5"
/>
<RadioBlock
label="Chatham Islands"
id="anyRadioId6234"
name="where"
value="chatham"
labelId="labelId6"
/>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="whereLiveTitle">
Where do you live?
</H1>
}
>
<RadioBlock
label="North Island"
id="anyRadioId3334"
name="where"
value="north"
labelId="labelId3"
/>
<RadioBlock
label="South Island"
id="anyRadioId42344"
name="where"
value="south"
labelId="labelId4"
/>
<RadioBlock
label="Stewart Island"
id="anyRadioId5234"
name="where"
value="stewart"
labelId="labelId5"
/>
<RadioBlock
label="Chatham Islands"
id="anyRadioId6234"
name="where"
value="chatham"
labelId="labelId6"
/>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block legend="Where do you live?">
<radio-block
label="North Island"
id="anyRadioId3334"
name="where"
value="north"
labelId="labelId3"
/>
<radio-block
label="South Island"
id="anyRadioId42344"
name="where"
value="south"
labelId="labelId4"
/>
<radio-block
label="Stewart Island"
id="anyRadioId5234"
name="where"
value="stewart"
labelId="labelId5"
/>
<radio-block
label="Chatham Islands"
id="anyRadioId6234"
name="where"
value="chatham"
labelId="labelId6"
/>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block legend="Where do you live?">
<radio-block
label="North Island"
id="anyRadioId3334"
name="where"
value="north"
labelId="labelId3"
/>
<radio-block
label="South Island"
id="anyRadioId42344"
name="where"
value="south"
labelId="labelId4"
/>
<radio-block
label="Stewart Island"
id="anyRadioId5234"
name="where"
value="stewart"
labelId="labelId5"
/>
<radio-block
label="Chatham Islands"
id="anyRadioId6234"
name="where"
value="chatham"
labelId="labelId6"
/>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset class="g-fieldsetBlock-fieldset">
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-s" id="whereLiveTitle">
Where do you live?
</h1>
</legend>
<div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId3334"
name="where"
type="radio"
value="north"
/>
<label class="g-radios__label" for="anyRadioId3334">
North Island
</label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId42344"
name="where"
type="radio"
value="south"
/>
<label class="g-radios__label" for="anyRadioId42344">
South Island
</label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId5234"
name="where"
type="radio"
value="stewart"
/>
<label class="g-radios__label" for="anyRadioId5234">
Stewart Island
</label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId6234"
name="where"
type="radio"
value="chatham"
/>
<label class="g-radios__label" for="anyRadioId6234">
Chatham Islands
</label>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'small', 'id':'whereLiveTitle', 'children':'Where do you live?'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'North Island', 'id':'anyRadioId3334', 'name':'where', 'value':'north', 'labelId':'labelId3'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'South Island', 'id':'anyRadioId42344', 'name':'where', 'value':'south', 'labelId':'labelId4'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'Stewart Island', 'id':'anyRadioId5234', 'name':'where', 'value':'stewart', 'labelId':'labelId5'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'Chatham Islands', 'id':'anyRadioId6234', 'name':'where', 'value':'chatham', 'labelId':'labelId6'} only %}{% endembed %}{% endblock %}{% endembed %}
When there are more than 2 options, radio buttons should be stacked.
Inline radio buttons
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import Radios from "@govtnz/ds/build/mustache/Radios.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, P, Radios, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=small": true,
styleSize: true,
id: `nameChangeId6`,
children: `Have you changed your name?`
})}`,
hint: `${Mustache.render(P, {
children: `This includes changing your last name or spelling your name differently.`
})}`,
hintId: `hintId2221`,
children: `${Mustache.render(Radios, {
inline: true,
children: `${Mustache.render(RadioBlock, {
label: `Yes`,
id: `anyRadioId55`,
value: `true`,
name: `nameChange1`,
labelId: `labelId1`
})}${Mustache.render(RadioBlock, {
label: `No`,
id: `anyRadioId2551`,
value: `false`,
name: `nameChange1`,
labelId: `labelId2`
})}`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-js/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId6">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId2221"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId55"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId2551"
value="false"
name="nameChange1"
labelId="labelId2"
/>
</Radios>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-ts/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId6">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId2221"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId55"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId2551"
value="false"
name="nameChange1"
labelId="labelId2"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import Radios from "@govtnz/ds/build/react-js-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId6">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId2221"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId55"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId2551"
value="false"
name="nameChange1"
labelId="labelId2"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import Radios from "@govtnz/ds/build/react-ts-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId6">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId2221"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId55"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId2551"
value="false"
name="nameChange1"
labelId="labelId2"
/>
</Radios>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId2221"
>
<c-radios inline>
<radio-block
label="Yes"
id="anyRadioId55"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<radio-block
label="No"
id="anyRadioId2551"
value="false"
name="nameChange1"
labelId="labelId2"
/>
</c-radios>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import Radios from "@govtnz/ds/build/vue-js/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId2221"
>
<c-radios inline>
<radio-block
label="Yes"
id="anyRadioId55"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<radio-block
label="No"
id="anyRadioId2551"
value="false"
name="nameChange1"
labelId="labelId2"
/>
</c-radios>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import Radios from "@govtnz/ds/build/vue-ts/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, Radios.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, Radios.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset class="g-fieldsetBlock-fieldset" aria-describedby="hintId2221">
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-s" id="nameChangeId6">
Have you changed your name?
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId2221">
<p class="g-body">
This includes changing your last name or spelling your name differently.
</p>
</div>
<div>
<div class="g-radios g-radios--inline">
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId55"
name="nameChange1"
type="radio"
value="true"
/>
<label class="g-radios__label" for="anyRadioId55"> Yes </label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId2551"
name="nameChange1"
type="radio"
value="false"
/>
<label class="g-radios__label" for="anyRadioId2551"> No </label>
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId2221'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'small', 'id':'nameChangeId6', 'children':'Have you changed your name?'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'This includes changing your last name or spelling your name differently.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "Radios.html.twig" with {'inline':'true'} only %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Yes', 'id':'anyRadioId55', 'value':'true', 'name':'nameChange1', 'labelId':'labelId1'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'No', 'id':'anyRadioId2551', 'value':'false', 'name':'nameChange1', 'labelId':'labelId2'} only %}{% endembed %}{% endblock %}{% endembed %}{% endblock %}{% endembed %}
If there are only 2 options, you can either stack the radio buttons or display them inline.
Radio button items with hints
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, P, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=small": true,
styleSize: true,
id: `providerChoiceTitle1`,
children: `Choose one provider`
})}`,
hint: `${Mustache.render(P, { children: `Select one provider.` })}`,
hintId: `hintId`,
children: `${Mustache.render(RadioBlock, {
label: `Sign in with Aardvark services`,
hint: `North Island only`,
hintId: `someHintId7`,
id: `anyRadioId7234`,
name: `providerChoice3`,
value: `provider1`,
labelId: `labelId5`
})}${Mustache.render(RadioBlock, {
label: `Sign in with Bumblebee services`,
hint: `North and South Island`,
hintId: `someHintId8`,
id: `anyRadioId8234`,
name: `providerChoice3`,
value: `provider2`,
labelId: `labelId8`
})}${Mustache.render(RadioBlock, {
label: `Sign in with Caterpillar company`,
hint: `All new Zealand territories`,
hintId: `someHintId7234`,
id: `anyRadioId9f`,
name: `providerChoice3`,
value: `provider3`,
labelId: `labelId9`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle1">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId"
>
<RadioBlock
label="Sign in with Aardvark services"
hint="North Island only"
hintId="someHintId7"
id="anyRadioId7234"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Bumblebee services"
hint="North and South Island"
hintId="someHintId8"
id="anyRadioId8234"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<RadioBlock
label="Sign in with Caterpillar company"
hint="All new Zealand territories"
hintId="someHintId7234"
id="anyRadioId9f"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle1">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId"
>
<RadioBlock
label="Sign in with Aardvark services"
hint="North Island only"
hintId="someHintId7"
id="anyRadioId7234"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Bumblebee services"
hint="North and South Island"
hintId="someHintId8"
id="anyRadioId8234"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<RadioBlock
label="Sign in with Caterpillar company"
hint="All new Zealand territories"
hintId="someHintId7234"
id="anyRadioId9f"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle1">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId"
>
<RadioBlock
label="Sign in with Aardvark services"
hint="North Island only"
hintId="someHintId7"
id="anyRadioId7234"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Bumblebee services"
hint="North and South Island"
hintId="someHintId8"
id="anyRadioId8234"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<RadioBlock
label="Sign in with Caterpillar company"
hint="All new Zealand territories"
hintId="someHintId7234"
id="anyRadioId9f"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle1">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId"
>
<RadioBlock
label="Sign in with Aardvark services"
hint="North Island only"
hintId="someHintId7"
id="anyRadioId7234"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Bumblebee services"
hint="North and South Island"
hintId="someHintId8"
id="anyRadioId8234"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<RadioBlock
label="Sign in with Caterpillar company"
hint="All new Zealand territories"
hintId="someHintId7234"
id="anyRadioId9f"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Choose one provider"
hint="Select one provider."
hintId="hintId"
>
<radio-block
label="Sign in with Aardvark services"
hint="North Island only"
hintId="someHintId7"
id="anyRadioId7234"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<radio-block
label="Sign in with Bumblebee services"
hint="North and South Island"
hintId="someHintId8"
id="anyRadioId8234"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<radio-block
label="Sign in with Caterpillar company"
hint="All new Zealand territories"
hintId="someHintId7234"
id="anyRadioId9f"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Choose one provider"
hint="Select one provider."
hintId="hintId"
>
<radio-block
label="Sign in with Aardvark services"
hint="North Island only"
hintId="someHintId7"
id="anyRadioId7234"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<radio-block
label="Sign in with Bumblebee services"
hint="North and South Island"
hintId="someHintId8"
id="anyRadioId8234"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<radio-block
label="Sign in with Caterpillar company"
hint="All new Zealand territories"
hintId="someHintId7234"
id="anyRadioId9f"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset class="g-fieldsetBlock-fieldset" aria-describedby="hintId">
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-s" id="providerChoiceTitle1">
Choose one provider
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId">
<p class="g-body">Select one provider.</p>
</div>
<div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId7234"
name="providerChoice3"
type="radio"
aria-describedby="someHintId7"
value="provider1"
/>
<label class="g-radios__label" for="anyRadioId7234">
Sign in with Aardvark services
</label>
<div class="g-radios__hint" id="someHintId7">North Island only</div>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId8234"
name="providerChoice3"
type="radio"
aria-describedby="someHintId8"
value="provider2"
/>
<label class="g-radios__label" for="anyRadioId8234">
Sign in with Bumblebee services
</label>
<div class="g-radios__hint" id="someHintId8">
North and South Island
</div>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId9f"
name="providerChoice3"
type="radio"
aria-describedby="someHintId7234"
value="provider3"
/>
<label class="g-radios__label" for="anyRadioId9f">
Sign in with Caterpillar company
</label>
<div class="g-radios__hint" id="someHintId7234">
All new Zealand territories
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'small', 'id':'providerChoiceTitle1', 'children':'Choose one provider'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'Select one provider.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Sign in with Aardvark services', 'hint':'North Island only', 'hintId':'someHintId7', 'id':'anyRadioId7234', 'name':'providerChoice3', 'value':'provider1', 'labelId':'labelId5'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'Sign in with Bumblebee services', 'hint':'North and South Island', 'hintId':'someHintId8', 'id':'anyRadioId8234', 'name':'providerChoice3', 'value':'provider2', 'labelId':'labelId8'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'Sign in with Caterpillar company', 'hint':'All new Zealand territories', 'hintId':'someHintId7234', 'id':'anyRadioId9f', 'name':'providerChoice3', 'value':'provider3', 'labelId':'labelId9'} only %}{% endembed %}{% endblock %}{% endembed %}
You can add hints to radio button items to provide more information about the options.
Radio button items with a text divider
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
import FormDivider from "@govtnz/ds/build/mustache/FormDivider.mustache";
// The variables FieldsetBlock, H1, P, RadioBlock, FormDivider are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=small": true,
styleSize: true,
id: `providerChoiceTitle2`,
children: `Choose one provider`
})}`,
hint: `${Mustache.render(P, { children: `Select one provider.` })}`,
hintId: `hintId234`,
children: `${Mustache.render(RadioBlock, {
label: `Sign in with Aardvark Services`,
hint: `North Island only`,
hintId: `someHintId72344`,
id: `anyRadioId7345`,
name: `providerChoice3`,
value: `provider1`,
labelId: `labelId5`
})}${Mustache.render(RadioBlock, {
label: `Sign in with Dandelion Services`,
hint: `South and Stewart Islands only`,
hintId: `someHintId8533`,
id: `anyRadioId8345`,
name: `providerChoice3`,
value: `provider2`,
labelId: `labelId8`
})}${Mustache.render(FormDivider, {
children: `${Mustache.render(P, { children: `-or-` })}`
})}${Mustache.render(RadioBlock, {
label: `Sign in with Eel Services`,
hint: `Non-New Zealand residents only`,
hintId: `someHintId7234444`,
id: `anyRadioId3459`,
name: `providerChoice3`,
value: `provider3`,
labelId: `labelId9`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
import FormDivider from "@govtnz/ds/build/react-js/FormDivider";
import "@govtnz/ds/build/css/FormDivider.css"; // or @govtnz/ds/build/scss/FormDivider.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle2">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId234"
>
<RadioBlock
label="Sign in with Aardvark Services"
hint="North Island only"
hintId="someHintId72344"
id="anyRadioId7345"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Dandelion Services"
hint="South and Stewart Islands only"
hintId="someHintId8533"
id="anyRadioId8345"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<FormDivider>
<P>-or-</P>
</FormDivider>
<RadioBlock
label="Sign in with Eel Services"
hint="Non-New Zealand residents only"
hintId="someHintId7234444"
id="anyRadioId3459"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
import FormDivider from "@govtnz/ds/build/react-ts/FormDivider";
import "@govtnz/ds/build/css/FormDivider.css"; // or @govtnz/ds/build/scss/FormDivider.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle2">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId234"
>
<RadioBlock
label="Sign in with Aardvark Services"
hint="North Island only"
hintId="someHintId72344"
id="anyRadioId7345"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Dandelion Services"
hint="South and Stewart Islands only"
hintId="someHintId8533"
id="anyRadioId8345"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<FormDivider>
<P>-or-</P>
</FormDivider>
<RadioBlock
label="Sign in with Eel Services"
hint="Non-New Zealand residents only"
hintId="someHintId7234444"
id="anyRadioId3459"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
import FormDivider from "@govtnz/ds/build/react-js-styled-components/FormDivider";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle2">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId234"
>
<RadioBlock
label="Sign in with Aardvark Services"
hint="North Island only"
hintId="someHintId72344"
id="anyRadioId7345"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Dandelion Services"
hint="South and Stewart Islands only"
hintId="someHintId8533"
id="anyRadioId8345"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<FormDivider>
<P>-or-</P>
</FormDivider>
<RadioBlock
label="Sign in with Eel Services"
hint="Non-New Zealand residents only"
hintId="someHintId7234444"
id="anyRadioId3459"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
import FormDivider from "@govtnz/ds/build/react-ts-styled-components/FormDivider";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="providerChoiceTitle2">
Choose one provider
</H1>
}
hint={<P>Select one provider.</P>}
hintId="hintId234"
>
<RadioBlock
label="Sign in with Aardvark Services"
hint="North Island only"
hintId="someHintId72344"
id="anyRadioId7345"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<RadioBlock
label="Sign in with Dandelion Services"
hint="South and Stewart Islands only"
hintId="someHintId8533"
id="anyRadioId8345"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<FormDivider>
<P>-or-</P>
</FormDivider>
<RadioBlock
label="Sign in with Eel Services"
hint="Non-New Zealand residents only"
hintId="someHintId7234444"
id="anyRadioId3459"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Choose one provider"
hint="Select one provider."
hintId="hintId234"
>
<radio-block
label="Sign in with Aardvark Services"
hint="North Island only"
hintId="someHintId72344"
id="anyRadioId7345"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<radio-block
label="Sign in with Dandelion Services"
hint="South and Stewart Islands only"
hintId="someHintId8533"
id="anyRadioId8345"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<form-divider>
<c-p>
-or-
</c-p>
</form-divider>
<radio-block
label="Sign in with Eel Services"
hint="Non-New Zealand residents only"
hintId="someHintId7234444"
id="anyRadioId3459"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
import FormDivider from "@govtnz/ds/build/vue-js/FormDivider.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"radio-block": RadioBlock,
"form-divider": FormDivider
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Choose one provider"
hint="Select one provider."
hintId="hintId234"
>
<radio-block
label="Sign in with Aardvark Services"
hint="North Island only"
hintId="someHintId72344"
id="anyRadioId7345"
name="providerChoice3"
value="provider1"
labelId="labelId5"
/>
<radio-block
label="Sign in with Dandelion Services"
hint="South and Stewart Islands only"
hintId="someHintId8533"
id="anyRadioId8345"
name="providerChoice3"
value="provider2"
labelId="labelId8"
/>
<form-divider>
<c-p>
-or-
</c-p>
</form-divider>
<radio-block
label="Sign in with Eel Services"
hint="Non-New Zealand residents only"
hintId="someHintId7234444"
id="anyRadioId3459"
name="providerChoice3"
value="provider3"
labelId="labelId9"
/>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
import FormDivider from "@govtnz/ds/build/vue-ts/FormDivider.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"radio-block": RadioBlock,
"form-divider": FormDivider
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, RadioBlock.css, FormDivider.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, RadioBlock.scss, FormDivider.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset class="g-fieldsetBlock-fieldset" aria-describedby="hintId234">
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-s" id="providerChoiceTitle2">
Choose one provider
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId234">
<p class="g-body">Select one provider.</p>
</div>
<div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId7345"
name="providerChoice3"
type="radio"
aria-describedby="someHintId72344"
value="provider1"
/>
<label class="g-radios__label" for="anyRadioId7345">
Sign in with Aardvark Services
</label>
<div class="g-radios__hint" id="someHintId72344">North Island only</div>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId8345"
name="providerChoice3"
type="radio"
aria-describedby="someHintId8533"
value="provider2"
/>
<label class="g-radios__label" for="anyRadioId8345">
Sign in with Dandelion Services
</label>
<div class="g-radios__hint" id="someHintId8533">
South and Stewart Islands only
</div>
</div>
<div class="g-form-divider"><p class="g-body">-or-</p></div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId3459"
name="providerChoice3"
type="radio"
aria-describedby="someHintId7234444"
value="provider3"
/>
<label class="g-radios__label" for="anyRadioId3459">
Sign in with Eel Services
</label>
<div class="g-radios__hint" id="someHintId7234444">
Non-New Zealand residents only
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId234'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'small', 'id':'providerChoiceTitle2', 'children':'Choose one provider'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'Select one provider.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Sign in with Aardvark Services', 'hint':'North Island only', 'hintId':'someHintId72344', 'id':'anyRadioId7345', 'name':'providerChoice3', 'value':'provider1', 'labelId':'labelId5'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'Sign in with Dandelion Services', 'hint':'South and Stewart Islands only', 'hintId':'someHintId8533', 'id':'anyRadioId8345', 'name':'providerChoice3', 'value':'provider2', 'labelId':'labelId8'} only %}{% endembed %}
{% embed "FormDivider.html.twig" %}{% block children %}{% embed "P.html.twig" with {'children':'-or-'} only %}{% endembed %}{% endblock %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'Sign in with Eel Services', 'hint':'Non-New Zealand residents only', 'hintId':'someHintId7234444', 'id':'anyRadioId3459', 'name':'providerChoice3', 'value':'provider3', 'labelId':'labelId9'} only %}{% endembed %}{% endblock %}{% endembed %}
If one or more of your radio button options is different from the others, it can help users if you separate them using a text divider. The text is usually the word ‘or’.
The default radio button size should be used in nearly all cases. However, larger versions work well on pages where it’s helpful to make them more visually prominent.
For example if you are asking users a single question on a page, larger buttons are easier to see and interact with.
Large radio buttons
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import Radios from "@govtnz/ds/build/mustache/Radios.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, P, Radios, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=large": true,
styleSize: true,
id: `nameChangeId1`,
children: `Have you changed your name?`
})}`,
hint: `${Mustache.render(P, {
children: `This includes changing your last name or spelling your name differently.`
})}`,
hintId: `hintId1`,
children: `${Mustache.render(Radios, {
inline: true,
big: ``,
children: `${Mustache.render(RadioBlock, {
label: `Yes`,
id: `anyRadioId`,
value: `true`,
name: `nameChange1`,
labelId: `labelId1`
})}${Mustache.render(RadioBlock, {
label: `No`,
id: `anyRadioId255`,
value: `false`,
name: `nameChange1`,
labelId: `labelId255`
})}`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-js/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId1">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-ts/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId1">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import Radios from "@govtnz/ds/build/react-js-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId1">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import Radios from "@govtnz/ds/build/react-ts-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId1">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId1"
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<RadioBlock
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</Radios>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId1"
>
<c-radios inline big>
<radio-block
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<radio-block
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</c-radios>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import Radios from "@govtnz/ds/build/vue-js/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId1"
>
<c-radios inline big>
<radio-block
label="Yes"
id="anyRadioId"
value="true"
name="nameChange1"
labelId="labelId1"
/>
<radio-block
label="No"
id="anyRadioId255"
value="false"
name="nameChange1"
labelId="labelId255"
/>
</c-radios>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import Radios from "@govtnz/ds/build/vue-ts/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, Radios.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, Radios.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset class="g-fieldsetBlock-fieldset" aria-describedby="hintId1">
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-l" id="nameChangeId1">
Have you changed your name?
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId1">
<p class="g-body">
This includes changing your last name or spelling your name differently.
</p>
</div>
<div>
<div class="g-radios g-radios--inline g-radios--big">
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId"
name="nameChange1"
type="radio"
value="true"
/>
<label class="g-radios__label" for="anyRadioId"> Yes </label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId255"
name="nameChange1"
type="radio"
value="false"
/>
<label class="g-radios__label" for="anyRadioId255"> No </label>
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId1'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'large', 'id':'nameChangeId1', 'children':'Have you changed your name?'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'This includes changing your last name or spelling your name differently.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "Radios.html.twig" with {'inline':'true', 'big':'true'} only %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Yes', 'id':'anyRadioId', 'value':'true', 'name':'nameChange1', 'labelId':'labelId1'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'No', 'id':'anyRadioId255', 'value':'false', 'name':'nameChange1', 'labelId':'labelId255'} only %}{% endembed %}{% endblock %}{% endembed %}{% endblock %}{% endembed %}
Error messages Make sure error messages follow the guidance below, and that you have specific error messages for specific error states.
Default radio buttons with error
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import Radios from "@govtnz/ds/build/mustache/Radios.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, P, Radios, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=small": true,
styleSize: true,
id: `nameChangeId8`,
children: `Have you changed your name?`
})}`,
hint: `${Mustache.render(P, {
children: `This includes changing your last name or spelling your name differently.`
})}`,
hintId: `hintId5344`,
errorId: true,
error: `Select 'yes' if you have changed your name`,
children: `${Mustache.render(Radios, {
inline: true,
children: `${Mustache.render(RadioBlock, {
label: `Yes`,
id: `anyRadioId9`,
value: `true`,
name: `nameChange5`,
labelId: `labelId9`
})}${Mustache.render(RadioBlock, {
label: `No`,
id: `anyRadioId10234`,
value: `false`,
name: `nameChange5`,
labelId: `labelId10`
})}`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-js/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId8">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5344"
errorId="errorId525"
error="Select 'yes' if you have changed your name"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId9"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10234"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-ts/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId8">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5344"
errorId="errorId525"
error="Select 'yes' if you have changed your name"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId9"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10234"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import Radios from "@govtnz/ds/build/react-js-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId8">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5344"
errorId="errorId525"
error="Select 'yes' if you have changed your name"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId9"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10234"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import Radios from "@govtnz/ds/build/react-ts-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="small" id="nameChangeId8">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5344"
errorId="errorId525"
error="Select 'yes' if you have changed your name"
>
<Radios inline>
<RadioBlock
label="Yes"
id="anyRadioId9"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10234"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId5344"
errorId="errorId525"
error="Select 'yes' if you have changed your name"
>
<c-radios inline>
<radio-block
label="Yes"
id="anyRadioId9"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<radio-block
label="No"
id="anyRadioId10234"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</c-radios>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import Radios from "@govtnz/ds/build/vue-js/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId5344"
errorId="errorId525"
error="Select 'yes' if you have changed your name"
>
<c-radios inline>
<radio-block
label="Yes"
id="anyRadioId9"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<radio-block
label="No"
id="anyRadioId10234"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</c-radios>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import Radios from "@govtnz/ds/build/vue-ts/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, Radios.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, Radios.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset
class="g-fieldsetBlock-fieldset"
aria-describedby="hintId5344 errorId525"
>
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-s" id="nameChangeId8">
Have you changed your name?
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId5344">
<p class="g-body">
This includes changing your last name or spelling your name differently.
</p>
</div>
<div class="g-fieldsetBlock-error-message" id="errorId525">
<span class="g-fieldsetBlock-visually-hidden"> Error: </span> Select 'yes'
if you have changed your name
</div>
<div>
<div class="g-radios g-radios--inline">
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId9"
name="nameChange5"
type="radio"
value="true"
/>
<label class="g-radios__label" for="anyRadioId9"> Yes </label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId10234"
name="nameChange5"
type="radio"
value="false"
/>
<label class="g-radios__label" for="anyRadioId10234"> No </label>
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId5344', 'errorId':'errorId525', 'error':'Select 'yes' if you have changed your name'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'small', 'id':'nameChangeId8', 'children':'Have you changed your name?'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'This includes changing your last name or spelling your name differently.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "Radios.html.twig" with {'inline':'true'} only %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Yes', 'id':'anyRadioId9', 'value':'true', 'name':'nameChange5', 'labelId':'labelId9'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'No', 'id':'anyRadioId10234', 'value':'false', 'name':'nameChange5', 'labelId':'labelId10'} only %}{% endembed %}{% endblock %}{% endembed %}{% endblock %}{% endembed %}
Large radio buttons with error
Code Mustache / Handlebars // Developer note: ensure your ".mustache" files are imported as plain text. In Webpack you might use https://github.com/webpack-contrib/raw-loader
import Mustache from "mustache";
import FieldsetBlock from "@govtnz/ds/build/mustache/FieldsetBlock.mustache";
import H1 from "@govtnz/ds/build/mustache/H1.mustache";
import P from "@govtnz/ds/build/mustache/P.mustache";
import Radios from "@govtnz/ds/build/mustache/Radios.mustache";
import RadioBlock from "@govtnz/ds/build/mustache/RadioBlock.mustache";
// The variables FieldsetBlock, H1, P, Radios, RadioBlock are all strings that are mustache templates.
export default `${Mustache.render(FieldsetBlock, {
legend: `${Mustache.render(H1, {
"styleSize=large": true,
styleSize: true,
id: `nameChangeId5`,
children: `Have you changed your name?`
})}`,
hint: `${Mustache.render(P, {
children: `This includes changing your last name or spelling your name differently.`
})}`,
hintId: `hintId5`,
errorId: true,
error: `Select 'yes' if you have changed your name.`,
children: `${Mustache.render(Radios, {
inline: true,
big: ``,
children: `${Mustache.render(RadioBlock, {
label: `Yes`,
id: `anyRadioId9234`,
value: `true`,
name: `nameChange5`,
labelId: `labelId9`
})}${Mustache.render(RadioBlock, {
label: `No`,
id: `anyRadioId10`,
value: `false`,
name: `nameChange5`,
labelId: `labelId10`
})}`
})}`
})}`;
React (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-js/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-js/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-js/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-js/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5"
errorId="errorId5"
error="Select 'yes' if you have changed your name."
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId9234"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
React (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts/FieldsetBlock";
import "@govtnz/ds/build/css/FieldsetBlock.css"; // or @govtnz/ds/build/scss/FieldsetBlock.scss
import H1 from "@govtnz/ds/build/react-ts/H1";
import "@govtnz/ds/build/css/H1.css"; // or @govtnz/ds/build/scss/H1.scss
import P from "@govtnz/ds/build/react-ts/P";
import "@govtnz/ds/build/css/P.css"; // or @govtnz/ds/build/scss/P.scss
import Radios from "@govtnz/ds/build/react-ts/Radios";
import "@govtnz/ds/build/css/Radios.css"; // or @govtnz/ds/build/scss/Radios.scss
import RadioBlock from "@govtnz/ds/build/react-ts/RadioBlock";
import "@govtnz/ds/build/css/RadioBlock.css"; // or @govtnz/ds/build/scss/RadioBlock.scss
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5"
errorId="errorId5"
error="Select 'yes' if you have changed your name."
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId9234"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (JavaScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-js-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-js-styled-components/H1";
import P from "@govtnz/ds/build/react-js-styled-components/P";
import Radios from "@govtnz/ds/build/react-js-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-js-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5"
errorId="errorId5"
error="Select 'yes' if you have changed your name."
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId9234"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
React with Styled Components (TypeScript) import React from "react";
import FieldsetBlock from "@govtnz/ds/build/react-ts-styled-components/FieldsetBlock";
import H1 from "@govtnz/ds/build/react-ts-styled-components/H1";
import P from "@govtnz/ds/build/react-ts-styled-components/P";
import Radios from "@govtnz/ds/build/react-ts-styled-components/Radios";
import RadioBlock from "@govtnz/ds/build/react-ts-styled-components/RadioBlock";
export default () => (
<FieldsetBlock
legend={
<H1 styleSize="large" id="nameChangeId5">
Have you changed your name?
</H1>
}
hint={
<P>
This includes changing your last name or spelling your name differently.
</P>
}
hintId="hintId5"
errorId="errorId5"
error="Select 'yes' if you have changed your name."
>
<Radios inline big>
<RadioBlock
label="Yes"
id="anyRadioId9234"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<RadioBlock
label="No"
id="anyRadioId10"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</Radios>
</FieldsetBlock>
);
Vue (JavaScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId5"
errorId="errorId5"
error="Select 'yes' if you have changed your name."
>
<c-radios inline big>
<radio-block
label="Yes"
id="anyRadioId9234"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<radio-block
label="No"
id="anyRadioId10"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</c-radios>
</fieldset-block>
</template>
<script>
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-js/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-js/H1.vue";
import P from "@govtnz/ds/build/vue-js/P.vue";
import Radios from "@govtnz/ds/build/vue-js/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-js/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
Vue (TypeScript) <template>
<fieldset-block
legend="Have you changed your name?"
hint="This includes changing your last name or spelling your name differently."
hintId="hintId5"
errorId="errorId5"
error="Select 'yes' if you have changed your name."
>
<c-radios inline big>
<radio-block
label="Yes"
id="anyRadioId9234"
value="true"
name="nameChange5"
labelId="labelId9"
/>
<radio-block
label="No"
id="anyRadioId10"
value="false"
name="nameChange5"
labelId="labelId10"
/>
</c-radios>
</fieldset-block>
</template>
<script lang="ts">
import Vue from "vue";
import FieldsetBlock from "@govtnz/ds/build/vue-ts/FieldsetBlock.vue";
import H1 from "@govtnz/ds/build/vue-ts/H1.vue";
import P from "@govtnz/ds/build/vue-ts/P.vue";
import Radios from "@govtnz/ds/build/vue-ts/Radios.vue";
import RadioBlock from "@govtnz/ds/build/vue-ts/RadioBlock.vue";
export default {
components: {
"fieldset-block": FieldsetBlock,
"c-h1": H1,
"c-p": P,
"c-radios": Radios,
"radio-block": RadioBlock
}
};
</script>
HTML <!--
Remember to add these styles:
in CSS: FieldsetBlock.css, H1.css, P.css, Radios.css, RadioBlock.css
OR in Sass (SCSS): FieldsetBlock.scss, H1.scss, P.scss, Radios.scss, RadioBlock.scss
-->
<div class="g-fieldsetBlock-form-group">
<fieldset
class="g-fieldsetBlock-fieldset"
aria-describedby="hintId5 errorId5"
>
<legend class="g-fieldsetBlock-fieldset__legend">
<h1 class="g-heading g-heading-l" id="nameChangeId5">
Have you changed your name?
</h1>
</legend>
<div class="g-fieldsetBlock-hint" id="hintId5">
<p class="g-body">
This includes changing your last name or spelling your name differently.
</p>
</div>
<div class="g-fieldsetBlock-error-message" id="errorId5">
<span class="g-fieldsetBlock-visually-hidden"> Error: </span> Select 'yes'
if you have changed your name.
</div>
<div>
<div class="g-radios g-radios--inline g-radios--big">
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId9234"
name="nameChange5"
type="radio"
value="true"
/>
<label class="g-radios__label" for="anyRadioId9234"> Yes </label>
</div>
<div class="g-radios__item">
<input
class="g-radios__input"
id="anyRadioId10"
name="nameChange5"
type="radio"
value="false"
/>
<label class="g-radios__label" for="anyRadioId10"> No </label>
</div>
</div>
</div>
</fieldset>
</div>
twig-embed {% embed "FieldsetBlock.html.twig" with {'hintId':'hintId5', 'errorId':'errorId5', 'error':'Select 'yes' if you have changed your name.'} only %}{% block legend %}{% embed "H1.html.twig" with {'styleSize':'large', 'id':'nameChangeId5', 'children':'Have you changed your name?'} only %}{% endembed %}{% endblock %}{% block hint %}{% embed "P.html.twig" with {'children':'This includes changing your last name or spelling your name differently.'} only %}{% endembed %}{% endblock %}{% block children %}{% embed "Radios.html.twig" with {'inline':'true', 'big':'true'} only %}{% block children %}{% embed "RadioBlock.html.twig" with {'label':'Yes', 'id':'anyRadioId9234', 'value':'true', 'name':'nameChange5', 'labelId':'labelId9'} only %}{% endembed %}
{% embed "RadioBlock.html.twig" with {'label':'No', 'id':'anyRadioId10', 'value':'false', 'name':'nameChange5', 'labelId':'labelId10'} only %}{% endembed %}{% endblock %}{% endembed %}{% endblock %}{% endembed %}
If nothing is selected and the options are ‘yes’ or ‘no’ Say ‘Select ‘yes’ if [whatever it is] is true’. For example, ‘Select ‘yes’ if Sarah normally lives with you’.
If nothing is selected and the question includes options Say ‘Select if [whatever it is]’. For example, ‘Select if you are employed or self-employed’.
If nothing is selected and the question does not include options [H4] Say ‘Select [whatever it is]’. For example, ‘Select the day of the week you pay your rent’.
Credit Guidance, original HTML and CSS derived from GOV.UK Design System .
Get in touch If you’ve got a question, idea, or suggestion, email the Design System (DS) team at info@digital.govt.nz , use our NZGDS Slack app , or discuss Radio buttons on 'GitHub issues'.