09Selection ring draw-in
Hovering or selecting a pickable card draws an SVG ring around its border in 0.3s via stroke-dashoffset, going all the way around to signal it's selected.
Best forSelectable plan cards, radio-style card picker UIs
SVG stroke-dashoffsetstroke-dasharray:focus-visible

<main class="stage">
<article class="card is-demo" tabindex="0">
<svg class="ring" viewBox="0 0 160 100" aria-hidden="true">
<rect class="ring__rect" x="2" y="2" width="156" height="96" rx="14" ry="14"></rect>
</svg>
<div class="card__body">
<h3 class="card__title">Basic plan</h3>
<p class="card__meta">4,900 KRW/mo</p>
</div>
</article>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-quick; // 링이 그려지는 시간
$easing: $ease-spring;
$color: $subject-blue; // 링 색
@include stage($stage-ink);
.stage { padding: clamp(8px, 2.4vw, 16px); }
.card {
position: relative;
width: min(160px, 50vw);
aspect-ratio: 8 / 5;
border-radius: $r-card;
background: $stage-paper;
box-shadow: $shadow-press;
padding: $sp-3;
box-sizing: border-box;
outline: none;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: center;
}
.ring {
position: absolute; inset: 0;
width: 100%; height: 100%;
pointer-events: none;
}
.ring__rect {
fill: none;
stroke: $color;
stroke-width: 3;
stroke-linecap: round;
stroke-dasharray: 500;
stroke-dashoffset: 500;
transition: stroke-dashoffset $duration $easing;
}
.card__title { margin: 0 0 $sp-1; font-weight: 700; font-size: clamp(12px, 3.4vw, 14px); line-height: 1.3; font-family: inherit; color: $stage-ink; }
.card__meta { margin: 0; font-weight: 500; font-size: clamp(11px, 3vw, 12px); line-height: 1.3; font-family: inherit; color: rgba($stage-ink, .6); }
.card:hover .ring__rect,
.card:focus-visible .ring__rect,
.card:active .ring__rect {
stroke-dashoffset: 0;
}
.card.is-demo .ring__rect { animation: ring-loop $dur-loop $easing infinite; }
@keyframes ring-loop {
0%, 10% { stroke-dashoffset: 500; }
55%, 80% { stroke-dashoffset: 0; }
100% { stroke-dashoffset: 500; }
}
@media (prefers-reduced-motion: reduce) {
.ring__rect { transition: none; }
.card.is-demo .ring__rect { animation: none; stroke-dashoffset: 0; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #17141a;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.stage {
padding: clamp(8px, 2.4vw, 16px);
}
.card {
position: relative;
width: min(160px, 50vw);
aspect-ratio: 8/5;
border-radius: 16px;
background: #ffffff;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
padding: 12px;
box-sizing: border-box;
outline: none;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: center;
}
.ring {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.ring__rect {
fill: none;
stroke: #2f6df6;
stroke-width: 3;
stroke-linecap: round;
stroke-dasharray: 500;
stroke-dashoffset: 500;
transition: stroke-dashoffset 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.card__title {
margin: 0 0 4px;
font-weight: 700;
font-size: clamp(12px, 3.4vw, 14px);
line-height: 1.3;
font-family: inherit;
color: #17141a;
}
.card__meta {
margin: 0;
font-weight: 500;
font-size: clamp(11px, 3vw, 12px);
line-height: 1.3;
font-family: inherit;
color: rgba(23, 20, 26, 0.6);
}
.card:hover .ring__rect,
.card:focus-visible .ring__rect,
.card:active .ring__rect {
stroke-dashoffset: 0;
}
.card.is-demo .ring__rect {
animation: ring-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes ring-loop {
0%, 10% {
stroke-dashoffset: 500;
}
55%, 80% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 500;
}
}
@media (prefers-reduced-motion: reduce) {
.ring__rect {
transition: none;
}
.card.is-demo .ring__rect {
animation: none;
stroke-dashoffset: 0;
}
}import type { CSSProperties } from "react";
import styles from "./SelectRingCard.module.scss";
export type SelectRingCardProps = {
title: string;
meta: string;
/** 링이 그려지는 시간 (기본 220ms) */
duration?: number;
easing?: string;
/** 링 색 */
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function SelectRingCard({
title,
meta,
duration = 220,
easing = "cubic-bezier(.2,.8,.2,1)",
color = "#2f6df6",
}: SelectRingCardProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<article className={styles.card} style={vars} tabIndex={0}>
<svg className={styles.ring} viewBox="0 0 160 100" aria-hidden="true">
<rect className={styles.ringRect} x={2} y={2} width={156} height={96} rx={14} ry={14} />
</svg>
<div className={styles.body}>
<h3 className={styles.title}>{title}</h3>
<p className={styles.meta}>{meta}</p>
</div>
</article>
);
}09 Selection ring draw-in — Measured area 1.335% · moving frames 11/23Original by GODRICH · SCSS and React ship in the zip · 9 CSS Card Hover Effects You Can Copy-Paste
The post this demo lives in
9 CSS Card Hover Effects You Can Copy-PasteCSS card hover effects are the short changes — a tilt, a flip, a badge popping in — that a card plays on hover, ready to See all demos in this post


