A speaker icon for a mute setting: checking folds the sound waves back into the cone, outer wave first, then draws an X in two strokes and fills the speaker. Unchecking lets the waves ripple back out.
Also known as: mute button checkbox css, sound on off icon css, volume mute animation.
<label class="chk-speaker-mute">
<input type="checkbox">
<svg class="chk-speaker-mute-icon" viewBox="0 0 24 24" aria-hidden="true">
<path class="chk-speaker-mute-cone" d="M3.5 9.5h3.2l4.8-4v13l-4.8-4H3.5z"/>
<path class="chk-speaker-mute-wave" d="M15 9.2a4 4 0 0 1 0 5.6"/>
<path class="chk-speaker-mute-wave" d="M17.8 6.5a7.8 7.8 0 0 1 0 11"/>
<path class="chk-speaker-mute-x" d="M15.5 9.5l5 5"/>
<path class="chk-speaker-mute-x" d="M20.5 9.5l-5 5"/>
</svg>
<span class="chk-speaker-mute-text">Mute</span>
</label>.chk-speaker-mute {
--c: var(--chk-color, #3b82f6);
font-size: var(--chk-size, 24px);
position: relative;
display: inline-flex;
align-items: center;
gap: 0.6em;
line-height: 1.3;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
gap: 0.5em;}
.chk-speaker-mute input {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
z-index: 1;
}
.chk-speaker-mute-icon {
flex: none;
width: 1.6em;
height: 1.6em;
overflow: visible;
border-radius: 0.3em;
color: color-mix(in srgb, currentColor 70%, transparent);
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
transition: color 0.25s ease;
}
.chk-speaker-mute-cone {
fill: transparent;
transform-box: fill-box;
transform-origin: 100% 50%;
transition: fill 0.25s ease;
}
.chk-speaker-mute-wave {
transform-box: view-box;
transform-origin: 48% 50%;
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s, opacity 0.25s ease 0.15s;
}
.chk-speaker-mute-wave + .chk-speaker-mute-wave {
transition-delay: 0.25s;
}
.chk-speaker-mute-x {
stroke-dasharray: 8;
stroke-dashoffset: 8;
transition: stroke-dashoffset 0.15s ease-in;
}
.chk-speaker-mute-text {
transition: color 0.25s ease;
}
.chk-speaker-mute:hover .chk-speaker-mute-icon {
color: var(--c);
}
.chk-speaker-mute input:checked + .chk-speaker-mute-icon {
color: var(--c);
}
.chk-speaker-mute input:checked + .chk-speaker-mute-icon .chk-speaker-mute-cone {
fill: var(--c);
animation: chk-speaker-mute-thump 0.4s ease-out 0.2s;
}
.chk-speaker-mute input:checked + .chk-speaker-mute-icon .chk-speaker-mute-wave {
opacity: 0;
transform: scale(0.3);
transition: transform 0.25s ease-in 0.08s, opacity 0.2s ease 0.1s;
}
.chk-speaker-mute input:checked + .chk-speaker-mute-icon .chk-speaker-mute-wave + .chk-speaker-mute-wave {
transition-delay: 0s;
}
.chk-speaker-mute input:checked + .chk-speaker-mute-icon .chk-speaker-mute-x {
stroke-dashoffset: 0;
transition: stroke-dashoffset 0.2s ease-out 0.3s;
}
.chk-speaker-mute input:checked + .chk-speaker-mute-icon .chk-speaker-mute-x + .chk-speaker-mute-x {
transition-delay: 0.45s;
}
.chk-speaker-mute input:checked ~ .chk-speaker-mute-text {
color: var(--c);
}
.chk-speaker-mute input:focus-visible + .chk-speaker-mute-icon {
outline: 0.12em solid var(--c);
outline-offset: 0.18em;
}
@keyframes chk-speaker-mute-thump {
0%, 100% { transform: scale(1); }
40% { transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
.chk-speaker-mute, .chk-speaker-mute *, .chk-speaker-mute::before, .chk-speaker-mute::after, .chk-speaker-mute *::before, .chk-speaker-mute *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--chk-color on the element or a parent.
Currently previewing #3b82f6.--chk-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 24px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.