Five bubbles pop up at scattered spots with a springy overshoot and merge into a solid fill. Each bubble reads its position and stagger from inline custom properties.
Also known as: bubbles hover button, circles fill hover, boiling fill button.
<button class="hfx-bubble-fill"> <span class="hfx-bubble-fill-bubbles" aria-hidden="true"><i style="--x: 6%; --y: 35%; --i: 1"></i><i style="--x: 28%; --y: 65%; --i: 3"></i><i style="--x: 50%; --y: 35%; --i: 0"></i><i style="--x: 72%; --y: 65%; --i: 4"></i><i style="--x: 94%; --y: 35%; --i: 2"></i></span> Order now </button>
.hfx-bubble-fill {
--c: var(--hfx-color, #3b82f6);
position: relative;
isolation: isolate;
overflow: hidden;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
padding: 0.75em 1.75em;
border-radius: 0.5em;
font: 600 var(--hfx-size, 16px)/1.2 system-ui, sans-serif;
white-space: nowrap;
cursor: pointer;
border: 2px solid var(--c);
background: transparent;
color: var(--c);
transition: color 0.25s ease 0.2s;
}
.hfx-bubble-fill-bubbles {
position: absolute;
inset: 0;
z-index: -1;
}
.hfx-bubble-fill-bubbles i {
position: absolute;
left: var(--x);
top: var(--y);
width: max(48%, 3.8em);
aspect-ratio: 1;
border-radius: 50%;
background: var(--c);
transform: translate(-50%, -50%) scale(0);
transition: transform 0.3s cubic-bezier(0.5, 0, 0.75, 0) calc((4 - var(--i)) * 0.03s);
}
.hfx-bubble-fill:is(:hover, :focus-visible) {
background-color: var(--c); /* hides the hairline where the fill meets the border */
color: #fff;
transition: color 0.25s ease 0.2s, background-color 0s 0.75s;
}
.hfx-bubble-fill:is(:hover, :focus-visible) .hfx-bubble-fill-bubbles i {
transform: translate(-50%, -50%) scale(1);
transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) calc(var(--i) * 0.06s);
}
@media (prefers-reduced-motion: reduce) {
.hfx-bubble-fill, .hfx-bubble-fill *, .hfx-bubble-fill::before, .hfx-bubble-fill::after, .hfx-bubble-fill *::before, .hfx-bubble-fill *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.