A conic gradient ring cut out with a radial mask. Unpicked rings rest in grayscale; the chosen one blooms into color, turns half a circle and a matching gradient dot spins in.
Also known as: gradient radio button css, colorful radio button css, conic gradient radio.
<div class="rad-gradient-radio" role="radiogroup" aria-label="Tone"> <label><input type="radio" name="rad-gradient-radio" value="calm"><span class="rad-gradient-radio-ring" aria-hidden="true"></span><span class="rad-gradient-radio-name">Calm</span></label> <label><input type="radio" name="rad-gradient-radio" value="bold" checked><span class="rad-gradient-radio-ring" aria-hidden="true"></span><span class="rad-gradient-radio-name">Bold</span></label> <label><input type="radio" name="rad-gradient-radio" value="wild"><span class="rad-gradient-radio-ring" aria-hidden="true"></span><span class="rad-gradient-radio-name">Wild</span></label> </div>
.rad-gradient-radio {
--c: var(--rad-color, #3b82f6);
font-size: var(--rad-size, 18px);
--g: conic-gradient(from 0deg, var(--c), color-mix(in srgb, var(--c) 25%, #ec4899), color-mix(in srgb, var(--c) 20%, #f59e0b), var(--c));
display: inline-flex;
gap: 1.8em;
font-family: system-ui, sans-serif;
line-height: 1.2;
}
.rad-gradient-radio label {
position: relative;
display: grid;
justify-items: center;
gap: 0.5em;
cursor: pointer;
}
.rad-gradient-radio input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.rad-gradient-radio-ring {
position: relative;
display: grid;
place-items: center;
width: 2em;
height: 2em;
border-radius: 50%;
}
.rad-gradient-radio-ring::before {
content: "";
position: absolute;
inset: 0;
border-radius: 50%;
background: var(--g);
-webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 0.22em), #000 calc(100% - 0.21em));
mask: radial-gradient(farthest-side, transparent calc(100% - 0.22em), #000 calc(100% - 0.21em));
filter: grayscale(1) opacity(0.45);
transition: filter 0.4s ease, transform 0.7s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.rad-gradient-radio-ring::after {
content: "";
width: 0.95em;
height: 0.95em;
border-radius: 50%;
background: var(--g);
box-shadow: 0 0 0.6em color-mix(in srgb, var(--c) 45%, transparent);
transform: scale(0) rotate(-180deg);
transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rad-gradient-radio label:hover .rad-gradient-radio-ring::before {
filter: grayscale(0.4) opacity(0.8);
}
.rad-gradient-radio input:checked + .rad-gradient-radio-ring::before {
filter: none;
transform: rotate(180deg);
}
.rad-gradient-radio input:checked + .rad-gradient-radio-ring::after {
transform: scale(1) rotate(0deg);
}
.rad-gradient-radio-name {
font-size: 0.85em;
font-weight: 700;
color: color-mix(in srgb, currentColor 60%, transparent);
transition: color 0.3s ease;
}
.rad-gradient-radio input:checked ~ .rad-gradient-radio-name {
background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 25%, #ec4899));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.rad-gradient-radio input:focus-visible + .rad-gradient-radio-ring {
outline: 0.12em solid var(--c);
outline-offset: 0.2em;
}
@media (prefers-reduced-motion: reduce) {
.rad-gradient-radio, .rad-gradient-radio *, .rad-gradient-radio::before, .rad-gradient-radio::after, .rad-gradient-radio *::before, .rad-gradient-radio *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--rad-color on the element or a parent.
Currently previewing #3b82f6.--rad-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 18px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.