06stroke-dashoffset 원형
SVG 원 하나가 stroke-dasharray 와 dashoffset 값만 바꿔 궤적을 그리듯 돈다.
쓰임정확한 퍼센트 없이 보여주는 대기 아이콘, 앱 스플래시 화면
stroke-dasharraySVG1.4초

<main class="stage">
<svg class="spinner" viewBox="0 0 44 44" width="56" height="56" role="status" aria-label="불러오는 중">
<circle class="spinner__track" cx="22" cy="22" r="18" fill="none" stroke-width="4"></circle>
<circle class="spinner__arc" cx="22" cy="22" r="18" fill="none" stroke-width="4"></circle>
</svg>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration-spin: 1.4s; // svg 전체가 도는 시간
$duration-dash: 1.4s; // 궤적이 늘었다 줄었다 하는 시간
$color: $subject-ink; // 궤적 색
@include stage($stage-yellow);
.spinner {
animation: spin $duration-spin linear infinite;
transform-origin: center;
}
.spinner__track {
stroke: rgba($subject-ink, .15);
}
.spinner__arc {
stroke: $color;
stroke-linecap: round;
stroke-dasharray: 113; // 2 * π * 18 ≈ 113
stroke-dashoffset: 90;
animation: dash $duration-dash ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@keyframes dash {
0% { stroke-dashoffset: 100; }
50% { stroke-dashoffset: 20; }
100% { stroke-dashoffset: 100; }
}
@media (prefers-reduced-motion: reduce) {
.spinner { animation: none; }
.spinner__arc { animation: none; stroke-dashoffset: 60; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffd23f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.spinner {
animation: spin 1.4s linear infinite;
transform-origin: center;
}
.spinner__track {
stroke: rgba(23, 20, 26, 0.15);
}
.spinner__arc {
stroke: #17141a;
stroke-linecap: round;
stroke-dasharray: 113;
stroke-dashoffset: 90;
animation: dash 1.4s ease-in-out infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@keyframes dash {
0% {
stroke-dashoffset: 100;
}
50% {
stroke-dashoffset: 20;
}
100% {
stroke-dashoffset: 100;
}
}
@media (prefers-reduced-motion: reduce) {
.spinner {
animation: none;
}
.spinner__arc {
animation: none;
stroke-dashoffset: 60;
}
}import type { CSSProperties } from "react";
import styles from "./DashCircleSpinner.module.scss";
export type DashCircleSpinnerProps = {
/** svg 전체가 도는 시간 (기본 1400ms) */
durationSpin?: number;
/** 궤적이 늘었다 줄었다 하는 시간 (기본 1400ms) */
durationDash?: number;
/** 궤적 색 */
color?: string;
label?: string;
};
type Vars = CSSProperties & { "--duration-spin"?: string; "--duration-dash"?: string; "--color"?: string };
export default function DashCircleSpinner({
durationSpin = 1400,
durationDash = 1400,
color = "#17141a",
label = "Loading",
}: DashCircleSpinnerProps) {
const vars: Vars = {
"--duration-spin": `${durationSpin}ms`,
"--duration-dash": `${durationDash}ms`,
"--color": color,
};
return (
<svg
className={styles.spinner}
style={vars}
viewBox="0 0 44 44"
width="56"
height="56"
role="status"
aria-label={label}
>
<circle className={styles.track} cx="22" cy="22" r="18" fill="none" strokeWidth="4" />
<circle className={styles.arc} cx="22" cy="22" r="18" fill="none" strokeWidth="4" />
</svg>
);
}06 stroke-dashoffset 원형 — 측정 누적면적 0.706% · 움직인 프레임 23/23GODRICH 원작 · zip 에 SCSS·React 포함 · CSS 로딩 스피너 9종 — div 하나로 끝나는
이 데모가 속한 글
CSS 로딩 스피너 9종 — div 하나로 끝나는CSS 로딩 스피너는 서버 응답을 기다리는 동안 화면이 멈추지 않았다는 걸 보여주는 작은 반복 애니메이션으로, 이 글은 자바스크립트 없이 CSS만으로 돌아가는 아홉 가지 방식을 모았습니다. 아홉 개 중 세 개는 흔한 이 글의 데모 전부 보기


