Two triangles slide in from opposite corners and meet along the diagonal. Each is a clip-path triangle drawn a touch oversize, so the join closes without a hairline gap.
Also known as: triangle fill hover, diagonal corners fill, split diagonal button.
<button class="hfx-diagonal-split-fill">Request access</button>
.hfx-diagonal-split-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.15s;
}
.hfx-diagonal-split-fill::before,
.hfx-diagonal-split-fill::after {
content: "";
position: absolute;
inset: -2px;
z-index: -1;
background: var(--c);
transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}
.hfx-diagonal-split-fill::before {
clip-path: polygon(0 0, 104% 0, 0 108%);
transform: translate(-100%, -100%);
}
.hfx-diagonal-split-fill::after {
clip-path: polygon(100% -8%, 100% 100%, -4% 100%);
transform: translate(100%, 100%);
}
.hfx-diagonal-split-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.15s, background-color 0s 0.45s;
}
.hfx-diagonal-split-fill:is(:hover, :focus-visible)::before,
.hfx-diagonal-split-fill:is(:hover, :focus-visible)::after {
transform: translate(0, 0);
}
@media (prefers-reduced-motion: reduce) {
.hfx-diagonal-split-fill, .hfx-diagonal-split-fill *, .hfx-diagonal-split-fill::before, .hfx-diagonal-split-fill::after, .hfx-diagonal-split-fill *::before, .hfx-diagonal-split-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.