The mic button from a video call: muted it is red with a slash, unmuted the slash retracts and the mic capsule fills with a live voice level. The level is a bar scaling on an uneven loop.
Also known as: unmute button, unmute microphone button css, mute mic toggle animation, meeting mic button.
<label class="btn-mic-unmute">
<input class="btn-mic-unmute-input" type="checkbox" aria-label="Unmute microphone">
<span class="btn-mic-unmute-face" aria-hidden="true">
<span class="btn-mic-unmute-mic">
<span class="btn-mic-unmute-capsule"></span>
<svg class="btn-mic-unmute-svg" viewBox="0 0 24 24"><path d="M5.5 11.5a6.5 6.5 0 0 0 13 0M12 18v3"/><path class="btn-mic-unmute-slash" d="M4.5 3.5l15 16" pathLength="1"/></svg>
</span>
<span class="btn-mic-unmute-text"><span>Unmute</span><span>Mute</span></span>
</span>
</label>.btn-mic-unmute {
--c: var(--btn-color, #3b82f6);
position: relative;
display: inline-grid;
place-items: center;
font: 600 var(--btn-size, 18px)/1.1 system-ui, sans-serif;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
--muted: color-mix(in srgb, #ef4444 82%, currentColor);}
.btn-mic-unmute-input {
position: absolute;
inset: 0;
z-index: 1;
width: 100%;
height: 100%;
margin: 0;
opacity: 0;
cursor: pointer;
border-radius: 2em;
}
.btn-mic-unmute-face {
display: inline-flex;
align-items: center;
gap: 0.5em;
padding: 0.6em 1.15em 0.6em 0.85em;
border-radius: 2em;
background-color: color-mix(in srgb, #ef4444 13%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, #ef4444 28%, transparent);
color: var(--muted);
transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.btn-mic-unmute-mic {
position: relative;
width: 1.4em;
height: 1.4em;
}
.btn-mic-unmute-capsule {
position: absolute;
top: 0.12em;
left: 0.5em;
width: 0.4em;
height: 0.68em;
box-sizing: border-box;
overflow: hidden;
border: 0.11em solid currentColor;
border-radius: 0.3em;
}
.btn-mic-unmute-capsule::before {
content: "";
position: absolute;
inset: 0;
background: currentColor;
transform: scaleY(0);
transform-origin: 50% 100%;
}
.btn-mic-unmute-svg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
fill: none;
stroke: currentColor;
stroke-width: 1.9;
stroke-linecap: round;
}
.btn-mic-unmute-slash {
stroke-dasharray: 1;
stroke-dashoffset: 0;
transition: stroke-dashoffset 0.3s cubic-bezier(0.65, 0, 0.35, 1);
}
.btn-mic-unmute-text {
display: grid;
min-width: 3.6em;
}
.btn-mic-unmute-text span {
grid-area: 1 / 1;
transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.btn-mic-unmute-text span + span {
opacity: 0;
transform: translateY(0.5em);
}
.btn-mic-unmute:hover .btn-mic-unmute-face { background-color: color-mix(in srgb, #ef4444 20%, transparent); }
.btn-mic-unmute:active .btn-mic-unmute-face { transform: scale(0.95); }
.btn-mic-unmute-input:focus-visible ~ .btn-mic-unmute-face {
outline: 2px solid var(--c);
outline-offset: 0.2em;
}
.btn-mic-unmute-input:checked ~ .btn-mic-unmute-face {
background-color: var(--c);
box-shadow: inset 0 0 0 1px var(--c), 0 0.5em 1.2em -0.5em var(--c);
color: #fff;
}
.btn-mic-unmute-input:checked ~ .btn-mic-unmute-face .btn-mic-unmute-slash { stroke-dashoffset: 1; }
.btn-mic-unmute-input:checked ~ .btn-mic-unmute-face .btn-mic-unmute-capsule::before {
animation: btn-mic-unmute-level 1.6s linear 0.25s infinite;
}
.btn-mic-unmute-input:checked ~ .btn-mic-unmute-face .btn-mic-unmute-text span:first-child {
opacity: 0;
transform: translateY(-0.5em);
}
.btn-mic-unmute-input:checked ~ .btn-mic-unmute-face .btn-mic-unmute-text span + span {
opacity: 1;
transform: none;
}
/* An uneven loop reads as a voice rather than a metronome. */
@keyframes btn-mic-unmute-level {
0%, 100% { transform: scaleY(0.2); }
9% { transform: scaleY(0.75); }
17% { transform: scaleY(0.4); }
28% { transform: scaleY(0.9); }
38% { transform: scaleY(0.3); }
47% { transform: scaleY(0.55); }
58% { transform: scaleY(0.15); }
70% { transform: scaleY(0.8); }
82% { transform: scaleY(0.45); }
91% { transform: scaleY(0.6); }
}
@media (prefers-reduced-motion: reduce) {
.btn-mic-unmute-input:checked ~ .btn-mic-unmute-face .btn-mic-unmute-capsule::before {
animation: none;
transform: scaleY(0.5);
}
}
@media (prefers-reduced-motion: reduce) {
.btn-mic-unmute, .btn-mic-unmute *, .btn-mic-unmute::before, .btn-mic-unmute::after, .btn-mic-unmute *::before, .btn-mic-unmute *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--btn-color on the element or a parent.
Currently previewing #3b82f6.--btn-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.