The fill sweeps around the center like a clock hand until it closes the circle. A conic gradient whose angle is a registered @property, so the browser can transition it.
Also known as: radial wipe button, conic gradient fill hover, pie fill button.
<button class="hfx-clock-wipe">Start timer</button>
@property --hfx-clock-wipe-a {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.hfx-clock-wipe {
--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.3s;
}
.hfx-clock-wipe::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
background: conic-gradient(var(--c) var(--hfx-clock-wipe-a), transparent 0);
transition: --hfx-clock-wipe-a 0.6s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-clock-wipe: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.3s, background-color 0s 0.6s;
}
.hfx-clock-wipe:is(:hover, :focus-visible)::before { --hfx-clock-wipe-a: 360deg; }
@media (prefers-reduced-motion: reduce) {
.hfx-clock-wipe, .hfx-clock-wipe *, .hfx-clock-wipe::before, .hfx-clock-wipe::after, .hfx-clock-wipe *::before, .hfx-clock-wipe *::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.