A ring detaches from the button's edge and moves out to a small gap on hover. It is the outline property with a growing outline-offset, so it follows the border radius and doubles as a focus ring.
Also known as: hvr-outline-out, outline offset animation, ring around button hover.
<button class="hfx-outline-out">Contact sales</button>
.hfx-outline-out {
--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;
outline: 2px solid transparent;
outline-offset: 0;
transition: outline-offset 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), outline-color 0.3s ease;}
.hfx-outline-out:is(:hover, :focus-visible) {
outline-color: var(--c);
outline-offset: 0.3em;
}
@media (prefers-reduced-motion: reduce) {
.hfx-outline-out, .hfx-outline-out *, .hfx-outline-out::before, .hfx-outline-out::after, .hfx-outline-out *::before, .hfx-outline-out *::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="rounded-lg bg-blue-500 px-6 py-3 font-semibold text-white outline outline-2 outline-offset-0 outline-transparent transition-all duration-300 ease-out hover:outline-offset-4 hover:outline-blue-500 focus-visible:outline-offset-4 focus-visible:outline-blue-500"> Contact sales </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.