08spinユーティリティ
既定の `animate-spin`(1秒)はそのままに、`@theme` に `--animate-spin-slow: spin 3s linear infinite` を足すだけで、ロゴとローディングリングが同じ回転を別々の速度で同時に回る。
使いどころロゴの装飾回転、更新ボタンと並ぶローディングリング
@keyframes spinrotate(360deg) 공유linear infinite

<main class="stage">
<div class="row">
<span class="ring ring--fast" aria-hidden="true"></span>
<span class="ring ring--slow" aria-hidden="true"></span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: 1000ms; // 기본 animate-spin 과 같은 1초
$easing: linear;
$color: $subject-blue;
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-paper);
.row {
display: flex;
align-items: center;
gap: $sp-8;
}
.ring {
box-sizing: border-box;
width: 56px;
height: 56px;
border-radius: 50%;
border: 5px solid rgba($subject-ink, .14);
}
// 기본 --animate-spin 그대로 (1초 linear)
.ring--fast {
border-top-color: $color;
animation: spin $duration $easing infinite;
}
// 확장한 --animate-spin-slow (3초 linear) — 같은 spin 키프레임을 속도만 다르게 공유
.ring--slow {
border-top-color: $subject-ink;
animation: spin 3000ms $easing infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
// ── 접근성 ──────────────────────────────────────────
@media (prefers-reduced-motion: reduce) {
.ring--fast, .ring--slow { animation: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffffff;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.row {
display: flex;
align-items: center;
gap: 32px;
}
.ring {
box-sizing: border-box;
width: 56px;
height: 56px;
border-radius: 50%;
border: 5px solid rgba(23, 20, 26, 0.14);
}
.ring--fast {
border-top-color: #2f6df6;
animation: spin 1000ms linear infinite;
}
.ring--slow {
border-top-color: #17141a;
animation: spin 3000ms linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: reduce) {
.ring--fast, .ring--slow {
animation: none;
}
}import type { CSSProperties } from "react";
import styles from "./SpinUtilRings.module.scss";
export type SpinUtilRingsProps = {
/** 기본 animate-spin 속도, ms */
duration?: number;
/** --animate-spin-slow 속도, ms */
slowDuration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & {
"--duration"?: string;
"--slow-duration"?: string;
"--easing"?: string;
"--color"?: string;
};
export default function SpinUtilRings({
duration = 1000,
slowDuration = 3000,
easing = "linear",
color = "#2f6df6",
}: SpinUtilRingsProps) {
const vars: Vars = {
"--duration": `${duration}ms`,
"--slow-duration": `${slowDuration}ms`,
"--easing": easing,
"--color": color,
};
return (
<div className={styles.row} style={vars}>
<span className={styles.ring} aria-hidden="true" />
<span className={`${styles.ring} ${styles["ring--slow"]}`} aria-hidden="true" />
</div>
);
}08 spinユーティリティ — 計測 累積面積 1.432% · 動いたフレーム 23/23GODRICH オリジナル · SCSS と React は zip に同梱 · Tailwind アニメーション9選(v4) 一行でコピペOK
このデモが属する記事
Tailwind アニメーション9選(v4) 一行でコピペOKtailwind アニメーションは、tailwind.config.jsを使わずCSSの@themeブロックに--animate-変数と@keyframesを一緒に書くと、その名前がそのままユーティリティクラスになるTailwind v4の この記事のデモをすべて見る

