A thin white frame settles inside the button's edge on hover, like the trim on a ticket or a badge. It is a pseudo-element that fades in while shrinking from just outside to its inset position.
Also known as: hvr-trim, inner border hover css, inset outline button.
<button class="hfx-trim">View tickets</button>
.hfx-trim {
--c: var(--hfx-color, #3b82f6);
display: inline-flex;
align-items: center;
gap: 0.5em;
padding: 0.7em 1.6em;
border-radius: 0.5em;
font: 600 var(--hfx-size, 16px) system-ui, sans-serif;
cursor: pointer;
border: 0;
background: var(--c);
color: #fff;
position: relative;}
.hfx-trim::before {
content: "";
position: absolute;
inset: 0.3em;
border: 2px solid rgb(255 255 255 / 0.85);
border-radius: 0.25em;
opacity: 0;
transform: scale(1.08, 1.25);
transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
pointer-events: none;
}
.hfx-trim:is(:hover, :focus-visible)::before {
opacity: 1;
transform: none;
}
@media (prefers-reduced-motion: reduce) {
.hfx-trim, .hfx-trim *, .hfx-trim::before, .hfx-trim::after, .hfx-trim *::before, .hfx-trim *::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.