<div class="grid-container">
<div class="column-two-thirds">
<div class="form-group">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">
Radio buttons
</h3>
</legend>
<div class="multiple-choice"><input id="radio-1" type="radio" name="radio-group-1" value="true">
<label for="radio-1">Private sector client</label>
</div>
<div class="multiple-choice"><input id="radio-2" type="radio" name="radio-group-1" value="false">
<label for="radio-2">Public sector client</label>
</div>
</fieldset>
</div>
<div class="form-group">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">Checkboxes</h3>
<p>Select all that apply</p>
</legend>
<div class="multiple-choice">
<input id="checkbox-1" name="checkboxes" type="checkbox" value="waste-animal">
<label for="checkbox-1">Waste from animal carcasses</label>
</div>
<div class="multiple-choice">
<input id="checkbox-2" name="checkboxes" type="checkbox" value="waste-mines">
<label for="checkbox-2">Waste from mines or quarries</label>
</div>
<div class="multiple-choice">
<input id="checkbox-3" name="checkboxes" type="checkbox" value="waste-farm-agricultural">
<label for="checkbox-3">Farm or agricultural waste</label>
</div>
</fieldset>
</div>
<hr/>
<h6 class="h6">Validation example</h6>
<div class="error-summary" role="alert" aria-labelledby="error-summary-heading-example-1" tabindex="-1">
<h4 class="h4 error-summary-heading" id="error-summary-heading-example-1">
Message to alert the user to a problem goes here
</h4>
<p>
Optional description of the errors and how to correct them
</p>
<ul class="error-summary-list">
<li>
<a href="#example-personal-details">Descriptive link to the question with an error</a>
</li>
</ul>
</div>
<div class="form-group form-group-error">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">
Radio buttons
</h4>
<p class="error-message">
Error message goes here
</p>
</legend>
<div class="multiple-choice"><input id="radio-1" type="radio" name="radio-group-1" value="true">
<label for="radio-1">Private sector client</label>
</div>
<div class="multiple-choice"><input id="radio-2" type="radio" name="radio-group-1" value="false">
<label for="radio-2">Public sector client</label>
</div>
</fieldset>
</div>
<div class="form-group form-group-error">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">Checkboxes</h3>
<p>Select all that apply</p>
<p class="error-message">
Error message goes here
</p>
</legend>
<div class="multiple-choice">
<input id="checkbox-1" name="checkboxes" type="checkbox" value="waste-animal">
<label for="checkbox-1">Waste from animal carcasses</label>
</div>
<div class="multiple-choice">
<input id="checkbox-2" name="checkboxes" type="checkbox" value="waste-mines">
<label for="checkbox-2">Waste from mines or quarries</label>
</div>
<div class="multiple-choice">
<input id="checkbox-3" name="checkboxes" type="checkbox" value="waste-farm-agricultural">
<label for="checkbox-3">Farm or agricultural waste</label>
</div>
</fieldset>
</div>
</div>
</div>
<div class="grid-container">
<div class="column-two-thirds">
<div class="form-group">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">
Radio buttons
</h3>
</legend>
<div class="multiple-choice"><input id="radio-1" type="radio" name="radio-group-1" value="true">
<label for="radio-1">Private sector client</label>
</div>
<div class="multiple-choice"><input id="radio-2" type="radio" name="radio-group-1" value="false">
<label for="radio-2">Public sector client</label>
</div>
</fieldset>
</div>
<div class="form-group">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">Checkboxes</h3>
<p>Select all that apply</p>
</legend>
<div class="multiple-choice">
<input id="checkbox-1" name="checkboxes" type="checkbox" value="waste-animal">
<label for="checkbox-1">Waste from animal carcasses</label>
</div>
<div class="multiple-choice">
<input id="checkbox-2" name="checkboxes" type="checkbox" value="waste-mines">
<label for="checkbox-2">Waste from mines or quarries</label>
</div>
<div class="multiple-choice">
<input id="checkbox-3" name="checkboxes" type="checkbox" value="waste-farm-agricultural">
<label for="checkbox-3">Farm or agricultural waste</label>
</div>
</fieldset>
</div>
<hr/>
<h6 class="h6">Validation example</h6>
<div class="error-summary" role="alert" aria-labelledby="error-summary-heading-example-1" tabindex="-1">
<h4 class="h4 error-summary-heading" id="error-summary-heading-example-1">
Message to alert the user to a problem goes here
</h4>
<p>
Optional description of the errors and how to correct them
</p>
<ul class="error-summary-list">
<li>
<a href="#example-personal-details">Descriptive link to the question with an error</a>
</li>
</ul>
</div>
<div class="form-group form-group-error">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">
Radio buttons
</h4>
<p class="error-message">
Error message goes here
</p>
</legend>
<div class="multiple-choice"><input id="radio-1" type="radio" name="radio-group-1" value="true">
<label for="radio-1">Private sector client</label>
</div>
<div class="multiple-choice"><input id="radio-2" type="radio" name="radio-group-1" value="false">
<label for="radio-2">Public sector client</label>
</div>
</fieldset>
</div>
<div class="form-group form-group-error">
<fieldset>
<legend>
<h4 class="h4 form-label form-label-bold">Checkboxes</h3>
<p>Select all that apply</p>
<p class="error-message">
Error message goes here
</p>
</legend>
<div class="multiple-choice">
<input id="checkbox-1" name="checkboxes" type="checkbox" value="waste-animal">
<label for="checkbox-1">Waste from animal carcasses</label>
</div>
<div class="multiple-choice">
<input id="checkbox-2" name="checkboxes" type="checkbox" value="waste-mines">
<label for="checkbox-2">Waste from mines or quarries</label>
</div>
<div class="multiple-choice">
<input id="checkbox-3" name="checkboxes" type="checkbox" value="waste-farm-agricultural">
<label for="checkbox-3">Farm or agricultural waste</label>
</div>
</fieldset>
</div>
</div>
</div>
/* No context defined for this component. */
// Radio buttons & checkboxes
// By default, multiple choice inputs stack vertically
.multiple-choice {
$is-ie: false;
display: block;
float: none;
clear: left;
position: relative;
padding: (8px 8px 9px 50px);
margin-bottom: 8px;
cursor: pointer; // Encourage clicking on the label
// remove 300ms pause on mobile
-ms-touch-action: manipulation;
touch-action: manipulation;
@include grid-media($sbc-grid-medium) {
float: left;
padding-top: 7px;
padding-bottom: 7px;
// width: 25%; - Test : check that text within labels will wrap
}
// Absolutely position inputs within label, to allow text to wrap
input {
position: absolute;
cursor: pointer;
left: 0;
top: 0;
width: 38px;
height: 38px;
z-index: 1;
// IE8 doesn’t support pseudoelements, so we don’t want to hide native elements there.
@if ($is-ie == false) or ($ie-version == 9) {
margin: 0;
opacity: 0;
}
}
label {
cursor: pointer;
}
[type=radio] + label::before {
content: "";
border: 2px solid;
background: transparent;
width: 34px;
height: 34px;
position: absolute;
top: 0;
left: 0;
border-radius: 100px;
}
[type=radio] + label::after {
content: "";
border: 10px solid;
width: 0;
height: 0;
position: absolute;
top: 9px;
left: 9px;
border-radius: 100px;
opacity: 0;
}
[type=checkbox] + label::before {
content: "";
border: 2px solid;
background: transparent;
width: 34px;
height: 34px;
position: absolute;
top: 0;
left: 0;
}
[type=checkbox] + label::after {
content: "";
border: solid;
border-width: 0 0 5px 5px;
background: transparent;
width: 17px;
height: 7px;
position: absolute;
top: 10px;
left: 8px;
-moz-transform: rotate(-45deg); // Firefox 15 compatibility
-o-transform: rotate(-45deg); // Opera 12.0 compatibility
-webkit-transform: rotate(-45deg); // Safari 8 compatibility
-ms-transform: rotate(-45deg); // IE9 compatibility
transform: rotate(-45deg);
opacity: 0;
}
// Focused state
[type=radio]:focus + label::before {
box-shadow: 0 0 0 4px $focus-colour;
}
[type=checkbox]:focus + label::before {
box-shadow: 0 0 0 3px $focus-colour;
}
// Selected state
input:checked + label::after {
opacity: 1;
}
// Disabled state
input:disabled + label {
opacity: 0.5;
}
&:last-child,
&:last-of-type {
margin-bottom: 0;
}
}
// To sit multiple choice inputs next to each other, use .inline on parent
.inline .multiple-choice {
clear: none;
@include grid-media($sbc-grid-medium) {
margin-bottom: 0;
margin-right: $gutter;
}
}
Radio buttons and checkboxes
govuk_modules/govuk_frontend_toolkit/stylesheets/_conditionals.scss)