The fill swings down from a hinge along the top edge, overshoots a little and settles, like a flap falling shut. A perspective rotateX with a damped linear() easing curve.
Also known as: hinge fill hover, flap fill button, 3d fold down button.
<button class="hfx-flip-down-fill">Open the vault</button>
.hfx-flip-down-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.2s ease 0.2s;
}
.hfx-flip-down-fill::before {
content: "";
position: absolute;
inset: -2px;
z-index: -1;
background: var(--c);
transform-origin: 50% 0;
transform: perspective(10em) rotateX(90deg);
transition: transform 0.35s cubic-bezier(0.5, 0, 0.75, 0);
}
.hfx-flip-down-fill:is(:hover, :focus-visible) {
background-color: var(--c); /* hides the hairline where the fill meets the border */
color: #fff;
transition: color 0.2s ease 0.2s, background-color 0s 0.8s;
}
.hfx-flip-down-fill:is(:hover, :focus-visible)::before {
transform: perspective(10em) rotateX(0deg);
transition: transform 0.8s linear(0, 0.2 12%, 0.55 24%, 1 36%, 1.1 45%, 1.12 50%, 1.1 55%, 1 64%, 0.97 72%, 0.975 76%, 1 86%, 1);
}
@media (prefers-reduced-motion: reduce) {
.hfx-flip-down-fill, .hfx-flip-down-fill *, .hfx-flip-down-fill::before, .hfx-flip-down-fill::after, .hfx-flip-down-fill *::before, .hfx-flip-down-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.