%main
%fieldset
.container
.svg
%input#radio-svg{:type => "radio", :name => "option"}
%div
%svg{:viewBox => "0 0 24 24"}
- 2.times do
%circle{:cx => "12", :cy => "12", :r => "8"}
%label{:for => "radio-svg"} SVG
%fieldset
.container
.svg
%input#radio-svg-2{:type => "radio", :name => "option"}
%div
%svg{:viewBox => "0 0 24 24"}
- 2.times do
%circle{:cx => "12", :cy => "12", :r => "8"}
%label{:for => "radio-svg-2"} SVG 2
View Compiled
fieldset {
.container {
display: flex;
align-items: center;
align-content: center;
}
label {
cursor: pointer;
margin-left: $p/2;
}
&:not(:first-child) {
margin-top: $p;
}
}
.svg {
position: relative;
overflow: hidden;
border-radius: 100%;
input {
cursor: pointer;
appearance: none;
opacity: 0;
position: absolute;
z-index: 10;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
}
div {
position: absolute;
z-index: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: mix($slate, $grey, 20%);
}
svg {
position: relative;
z-index: 2;
display: block;
width: 24px;
height: 24px;
circle {
&:nth-child(1) {
fill: mix(white, $slate, 80%);
}
&:nth-child(2) {
transform-origin: center center;
transform: scale(0);
fill: $blue;
}
}
}
input {
&:hover {
~ svg {
circle:nth-child(1) {
fill: mix(mix($slate, $grey, 20%), $blue, 80%);
}
}
}
&:active, &:checked {
~ div {
background: white;
}
~ svg {
circle:nth-child(2) {
transform: scale(1);
}
}
}
}
}
View Compiled
This Pen doesn't use any external JavaScript resources.