CSS Outline Offset Hover
A ring that springs out from the element on hover and focus by animating outline-offset and outline color.
<div class="ring-row">
<a class="ring-hover" href="#" aria-label="Profile of Kai">K</a>
<a class="ring-hover" href="#" aria-label="Profile of Noa">N</a>
<a class="ring-hover" href="#" aria-label="Profile of Eli">E</a>
</div>
.ring-row {
display: flex;
gap: 18px;
}
.ring-hover {
display: grid;
place-items: center;
width: 56px;
height: 56px;
border-radius: 50%;
background: #0d9488;
color: #fff;
font: 700 20px system-ui, sans-serif;
text-decoration: none;
outline: 2px solid transparent;
outline-offset: 0;
transition: outline-offset 0.25s ease, outline-color 0.25s ease;
}
.ring-hover:hover,
.ring-hover:focus-visible {
outline-color: #0d9488;
outline-offset: 5px;
}
@media (prefers-reduced-motion: reduce) {
.ring-hover {
transition: none;
}
}
About this CSS Outline Offset Hover
This CSS Outline Offset Hover is 31 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses transitions, CSS Grid, Flexbox and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#0d9488#fff
How to use this outline offset hover
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.ring-rowclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.