Soft UI radios on their own surface: each well sits raised until chosen, then sinks in as its shadows flip to inset and a glowing accent dot rises out of the middle.
Also known as: neumorphism radio button css, soft ui radio buttons.
<div class="rad-neumorphic-radio" role="radiogroup" aria-label="Mode"> <label><input type="radio" name="rad-neumorphic-radio" value="eco"><span class="rad-neumorphic-radio-well" aria-hidden="true"></span><span class="rad-neumorphic-radio-name">Eco</span></label> <label><input type="radio" name="rad-neumorphic-radio" value="normal" checked><span class="rad-neumorphic-radio-well" aria-hidden="true"></span><span class="rad-neumorphic-radio-name">Normal</span></label> <label><input type="radio" name="rad-neumorphic-radio" value="sport"><span class="rad-neumorphic-radio-well" aria-hidden="true"></span><span class="rad-neumorphic-radio-name">Sport</span></label> </div>
.rad-neumorphic-radio {
--c: var(--rad-color, #3b82f6);
font-size: var(--rad-size, 18px);
--surface: color-mix(in srgb, var(--c) 6%, #e3e7ee);
--low: color-mix(in srgb, var(--c) 14%, #a3afc2);
display: inline-flex;
gap: 1.5em;
padding: 1.2em 1.7em 1em;
border-radius: 1.2em;
background: var(--surface);
color: #5b6475;
font-weight: 600;
font-family: system-ui, sans-serif;
line-height: 1.2;
}
.rad-neumorphic-radio label {
position: relative;
display: grid;
justify-items: center;
gap: 0.7em;
cursor: pointer;
}
.rad-neumorphic-radio input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.rad-neumorphic-radio-well {
display: grid;
place-items: center;
width: 2.3em;
height: 2.3em;
border-radius: 50%;
background: var(--surface);
box-shadow:
0.3em 0.3em 0.6em var(--low),
-0.3em -0.3em 0.6em #fff,
inset 0 0 0 transparent,
inset 0 0 0 transparent;
transition: box-shadow 0.35s ease;
}
.rad-neumorphic-radio-well::after {
content: "";
width: 0.75em;
height: 0.75em;
border-radius: 50%;
background: var(--c);
box-shadow: 0 0 0.6em var(--c);
transform: scale(0);
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rad-neumorphic-radio input:checked + .rad-neumorphic-radio-well {
box-shadow:
0 0 0 transparent,
0 0 0 transparent,
inset 0.25em 0.25em 0.5em var(--low),
inset -0.25em -0.25em 0.5em #fff;
}
.rad-neumorphic-radio input:checked + .rad-neumorphic-radio-well::after {
transform: scale(1);
transition-delay: 0.1s;
}
.rad-neumorphic-radio-name {
font-size: 0.8em;
transition: color 0.25s ease;
}
.rad-neumorphic-radio input:checked ~ .rad-neumorphic-radio-name {
color: var(--c);
}
.rad-neumorphic-radio input:focus-visible + .rad-neumorphic-radio-well {
outline: 0.12em solid var(--c);
outline-offset: 0.3em;
}
@media (prefers-reduced-motion: reduce) {
.rad-neumorphic-radio, .rad-neumorphic-radio *, .rad-neumorphic-radio::before, .rad-neumorphic-radio::after, .rad-neumorphic-radio *::before, .rad-neumorphic-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.