Two panels slide in from the left and right edges and meet in the middle, like doors closing. Each panel is a pseudo-element a hair over half wide, so no seam shows where they meet.
Also known as: split doors button, fill from both sides hover, shutter in horizontal.
<button class="hfx-shutter-in">Book a call</button>
.hfx-shutter-in {
--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.12s;
}
.hfx-shutter-in::before,
.hfx-shutter-in::after {
content: "";
position: absolute;
top: 0;
bottom: 0;
z-index: -1;
width: 51%;
background: var(--c);
transition: transform 0.4s cubic-bezier(0.7, 0, 0.2, 1);
}
.hfx-shutter-in::before {
left: 0;
transform: translateX(-100%);
}
.hfx-shutter-in::after {
right: 0;
transform: translateX(100%);
}
.hfx-shutter-in: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.12s, background-color 0s 0.4s;
}
.hfx-shutter-in:is(:hover, :focus-visible)::before,
.hfx-shutter-in:is(:hover, :focus-visible)::after {
transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
.hfx-shutter-in, .hfx-shutter-in *, .hfx-shutter-in::before, .hfx-shutter-in::after, .hfx-shutter-in *::before, .hfx-shutter-in *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}The same effect using Tailwind utility classes. No custom CSS or config needed.
<button class="group relative isolate overflow-hidden rounded-lg border-2 border-blue-500 px-7 py-3 font-semibold text-blue-500 transition-colors delay-100 duration-300 hover:text-white"> <span class="absolute inset-y-0 left-0 -z-10 w-[51%] -translate-x-full bg-blue-500 transition-transform duration-500 ease-in-out group-hover:translate-x-0"></span> <span class="absolute inset-y-0 right-0 -z-10 w-[51%] translate-x-full bg-blue-500 transition-transform duration-500 ease-in-out group-hover:translate-x-0"></span> Book a call </button>
--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.