Radio Button Component
A CSS implementation of the Sprout radio button component.
Related
Sprout Radio Group documentation [external]
.spr-radio-btn-group-container
scss
.spr-radio-btn-group-container {
@include spr-space-stack-container(xxs);
.spr-radio-btn-group-label {
@include spr-text(label-sm);
font-weight: spr-font-weight(bold);
}
}
Example
html
<div class="spr-radio-btn-group-container">
<div class="spr-radio-btn-group-label">Languages</div>
<div class="spr-inline-container-md">
<div class="spr-radio-btn-container">
<input class="spr-radio-btn" type="radio" name="languages" id="csharp" value="csharp">
<label for="csharp">C#</label>
</div>
<div class="spr-radio-btn-container">
<input checked class="spr-radio-btn" type="radio" name="languages" id="ts" value="ts">
<label for="ts">Typescript</label>
</div>
<div class="spr-radio-btn-container">
<input class="spr-radio-btn spr-radio-btn-error" type="radio" name="languages" id="java" value="java">
<label for="java">Java</label>
</div>
<div class="spr-radio-btn-container">
<input disabled class="spr-radio-btn" type="radio" name="languages" id="python" value="python">
<label for="python">Python</label>
</div>
</div>
</div>
Compiled CSS
Example
scss
@import 'components/radio-button';
css
compiled
@keyframes openPopover {
from {
transform: scale(0.9);
}
to {
transform: scale(1);
}
}
.spr-radio-btn-group-container {
display: flex;
flex-direction: column;
}
.spr-radio-btn-group-container > :not(:last-child) {
margin-bottom: 0.25rem;
}
.spr-radio-btn-group-container .spr-radio-btn-group-label {
font-family: "AvenirNext", "Helvetica Neue", Arial, sans-serif;
font-size: 0.875rem;
line-height: 1.25rem;
letter-spacing: 0;
font-weight: 400;
font-weight: 600;
}
.spr-radio-btn-container {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.spr-radio-btn-container > :not(:last-child) {
margin-right: 0.5rem;
}
.spr-radio-btn-container .spr-radio-btn {
appearance: none;
outline: none;
min-width: 18px;
height: 18px;
background-color: #fff;
margin-top: 0rem;
margin-left: 0rem;
cursor: pointer;
user-select: none;
margin-right: 0.5rem;
box-sizing: border-box;
border: 1px solid #6b6f7b;
border-radius: 50%;
}
.spr-radio-btn-container .spr-radio-btn:hover {
box-sizing: border-box;
border: 2px solid #2ba148;
border-radius: 50%;
}
.spr-radio-btn-container .spr-radio-btn:focus {
box-sizing: border-box;
border: 2px solid #2ba148;
border-radius: 50%;
box-shadow: 0 0 0 0.125rem rgba(43, 161, 72, 0.35);
}
.spr-radio-btn-container .spr-radio-btn:checked {
border: 5px solid #2ba148;
}
.spr-radio-btn-container .spr-radio-btn:checked:hover {
border: 5px solid #22813a;
}
.spr-radio-btn-container .spr-radio-btn:checked:focus {
border: 5px solid #22813a;
box-shadow: 0 0 0 0.125rem rgba(43, 161, 72, 0.35);
}
.spr-radio-btn-container .spr-radio-btn:disabled,
.spr-radio-btn-container .spr-radio-btn:disabled + label {
cursor: default;
pointer-events: none;
opacity: 0.5;
}
.spr-radio-btn-container .spr-radio-btn-error {
box-sizing: border-box;
border: 1px solid #dd1d33;
border-radius: 50%;
}
.spr-radio-btn-container .spr-radio-btn-error:hover {
box-sizing: border-box;
border: 2px solid #dd1d33;
border-radius: 50%;
}
.spr-radio-btn-container .spr-radio-btn-error:focus {
box-sizing: border-box;
border: 2px solid #dd1d33;
border-radius: 50%;
box-shadow: 0 0 0 0.125rem rgba(221, 29, 51, 0.35);
}
.spr-radio-btn-container .spr-radio-btn-error:checked {
border: 5px solid #dd1d33;
}
.spr-radio-btn-container .spr-radio-btn-error:checked:hover {
border: 5px solid #b9182b;
}
.spr-radio-btn-container .spr-radio-btn-error:checked:focus {
border: 5px solid #b9182b;
box-shadow: 0 0 0 0.125rem rgba(221, 29, 51, 0.35);
}
.spr-radio-btn-container .spr-radio-btn-error:disabled,
.spr-radio-btn-container .spr-radio-btn-error:disabled + label {
cursor: default;
pointer-events: none;
opacity: 0.5;
}
.spr-radio-btn-container .spr-radio-btn + label {
cursor: pointer;
user-select: none;
}