05group-hover 아이콘
부모에 `group`을 걸고 아이콘에 `group-hover:translate-x-1`을 걸면, 카드 어디를 호버하든 안쪽 화살표만 오른쪽으로 4px 미끄러진다.
쓰임카드형 CTA, 리스트 항목 화살표
.card:hover 자식translateX(4px)200ms
<main class="stage">
<a class="card group is-demo" href="#" onclick="return false">
<span class="card__text">더 알아보기</span>
<span class="arrow">
<span class="arrow__line"></span>
<span class="arrow__head"></span>
</span>
</a>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: 200ms;
$easing: ease-out;
$color: $subject-blue;
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-ink);
.card {
display: inline-flex;
align-items: center;
gap: $sp-3;
padding: $sp-4 $sp-6;
border-radius: $r-control;
background: rgba($subject-cream, .08);
border: 1px solid rgba($subject-cream, .18);
text-decoration: none;
cursor: pointer;
}
.card__text {
color: $subject-cream;
font-weight: 600;
font-size: clamp(14px, 4vw, 16px);
line-height: 1;
font-family: inherit;
}
.arrow {
position: relative;
width: 18px;
height: 14px;
}
.arrow__line {
position: absolute;
left: 0; top: 6px;
width: 14px; height: 2px;
background: $color;
transform-origin: left center; // 규칙8: 화살대 왼쪽 고정 신장
transition: transform $duration $easing;
}
.arrow__head {
position: absolute;
right: 0; top: 1px;
width: 9px; height: 9px;
border-top: 2px solid $color;
border-right: 2px solid $color;
transform: rotate(45deg);
transition: transform $duration $easing;
}
// 실사용: group-hover — 카드 어디를 호버해도 화살표만 오른쪽으로 4px
.card:hover .arrow__line,
.card:focus-visible .arrow__line { transform: translateX(4px) scaleX(1.08); }
.card:hover .arrow__head,
.card:focus-visible .arrow__head { transform: translate(4px, 0) rotate(45deg); }
// 데모: 호버를 걸 수 없으니 2초마다 같은 움직임을 스스로 반복
.card.is-demo .arrow__line { animation: nudge-line 2s $easing infinite; }
.card.is-demo .arrow__head { animation: nudge-head 2s $easing infinite; }
@keyframes nudge-line {
0%, 30% { transform: translateX(0) scaleX(1); }
55% { transform: translateX(4px) scaleX(1.08); }
80%, 100% { transform: translateX(0) scaleX(1); }
}
@keyframes nudge-head {
0%, 30% { transform: translate(0, 0) rotate(45deg); }
55% { transform: translate(4px, 0) rotate(45deg); }
80%, 100% { transform: translate(0, 0) rotate(45deg); }
}
// ── 접근성 ──────────────────────────────────────────
@media (prefers-reduced-motion: reduce) {
.arrow__line, .arrow__head { transition: none; }
.card.is-demo .arrow__line, .card.is-demo .arrow__head { animation: none; }
}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);
}
.card {
display: inline-flex;
align-items: center;
gap: 12px;
padding: 16px 24px;
border-radius: 12px;
background: rgba(255, 247, 230, 0.08);
border: 1px solid rgba(255, 247, 230, 0.18);
text-decoration: none;
cursor: pointer;
}
.card__text {
color: #fff7e6;
font-weight: 600;
font-size: clamp(14px, 4vw, 16px);
line-height: 1;
font-family: inherit;
}
.arrow {
position: relative;
width: 18px;
height: 14px;
}
.arrow__line {
position: absolute;
left: 0;
top: 6px;
width: 14px;
height: 2px;
background: #2f6df6;
transform-origin: left center;
transition: transform 200ms ease-out;
}
.arrow__head {
position: absolute;
right: 0;
top: 1px;
width: 9px;
height: 9px;
border-top: 2px solid #2f6df6;
border-right: 2px solid #2f6df6;
transform: rotate(45deg);
transition: transform 200ms ease-out;
}
.card:hover .arrow__line,
.card:focus-visible .arrow__line {
transform: translateX(4px) scaleX(1.08);
}
.card:hover .arrow__head,
.card:focus-visible .arrow__head {
transform: translate(4px, 0) rotate(45deg);
}
.card.is-demo .arrow__line {
animation: nudge-line 2s ease-out infinite;
}
.card.is-demo .arrow__head {
animation: nudge-head 2s ease-out infinite;
}
@keyframes nudge-line {
0%, 30% {
transform: translateX(0) scaleX(1);
}
55% {
transform: translateX(4px) scaleX(1.08);
}
80%, 100% {
transform: translateX(0) scaleX(1);
}
}
@keyframes nudge-head {
0%, 30% {
transform: translate(0, 0) rotate(45deg);
}
55% {
transform: translate(4px, 0) rotate(45deg);
}
80%, 100% {
transform: translate(0, 0) rotate(45deg);
}
}
@media (prefers-reduced-motion: reduce) {
.arrow__line, .arrow__head {
transition: none;
}
.card.is-demo .arrow__line, .card.is-demo .arrow__head {
animation: none;
}
}import type { CSSProperties, MouseEvent } from "react";
import styles from "./GroupHoverIconCard.module.scss";
export type GroupHoverIconCardProps = {
label?: string;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function GroupHoverIconCard({
label = "Learn more",
duration = 200,
easing = "ease-out",
color = "#2f6df6",
}: GroupHoverIconCardProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<a className={styles.card} href="#" style={vars} onClick={(e: MouseEvent) => e.preventDefault()}>
<span className={styles.card__text}>{label}</span>
<span className={styles.arrow}>
<span className={styles.arrow__line} />
<span className={styles.arrow__head} />
</span>
</a>
);
}05 group-hover 아이콘 — 측정 누적면적 0.098% · 움직인 프레임 12/23GODRICH 원작 · zip 에 SCSS·React 포함 · Tailwind 애니메이션 유틸 9종(v4) — 한 줄 복붙으로
이 데모가 속한 글
Tailwind 애니메이션 유틸 9종(v4) — 한 줄 복붙으로Tailwind 애니메이션은 tailwind.config.js가 아니라 CSS 파일 안 @theme 블록에 --animate- 변수와 @keyframes를 같이 적어서 만드는 Tailwind v4의 새 방식입니다. 이 글의 데모 전부 보기
