웹 토스트 알림 CSS 애니메이션 9종 — JS 없이, CSS만으로
웹 토스트 알림은 화면 한쪽에 잠깐 떴다가 스스로 사라지는 작은 알림 카드로, 사용자가 지금 보던 화면을 벗어나지 않아도 결과를 알 수 있게 해 줍니다. 슬라이드로 들어오는 것부터 스와이프로 미는 것, 진행바가 다 닳으면 닫히는 것까지 아홉 가지를 모았습니다.
01 toast-notification-slide-in-right
02 toast-notification-popover-toast
03 toast-notification-stack-3
04 toast-notification-progress-close
05 toast-notification-undo-toast
06 toast-notification-swipe-dismiss
08 toast-notification-bottom-mobile
09 toast-notification-bell-badge
자동 재생 · 눌러서 해당 항목으로 · 전부 한 zip
- 01 오른쪽 슬라이드 인
- 02 Popover API 토스트
- 03 3개 스택
- 04 남은 시간 바
- 05 되돌리기 토스트
- 06 스와이프로 닫기
- 07 성공 아이콘
- 08 모바일 하단 토스트
- 09 알림 배지
아홉 개는 인기 순이 아니라 알림 토스트 하나가 화면에서 겪는 순서로 놓았습니다. 눈에 띄는 등장 방식(01~03), 스스로 정리되는 법(04~06), 상태를 색과 모양으로 말하는 법(07~09) 순서입니다. 같은 열고 닫기 문법을 내비게이션에 매달면 CSS 드롭다운 메뉴가 되고, 화면 가장자리에서 밀려 나오는 판까지 키우면 사이드바 드로어가 됩니다.
01오른쪽 슬라이드 인
화면 밖에서 미끄러져 들어오기
카드가 화면 오른쪽 밖에서 translateX로 미끄러져 들어와 잠깐 머물다 같은 방향으로 빠져나갑니다.

<main class="stage">
<div class="toast is-demo" role="status" aria-live="polite">
<span class="toast__bar" aria-hidden="true"></span>
<div class="toast__body">
<p class="toast__title">저장 완료</p>
<p class="toast__text">새 항목이 저장되었습니다</p>
</div>
<button class="toast__close" type="button" aria-label="알림 닫기">
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true">
<line x1="5" y1="5" x2="19" y2="19" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
<line x1="19" y1="5" x2="5" y2="19" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
</svg>
</button>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-enter; // 600ms — 오른쪽에서 미끄러져 들어오는 시간
$easing: $ease-spring;
$color: $subject-blue; // 왼쪽 강조 막대 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-ink);
// 실측 2026-09-10: 토스트가 오른쪽 밖(translateX 140%)에서 들어온다 — html/body 의 overflow:hidden 은
// 뷰포트로 전파돼 scrollWidth 를 못 줄인다(320px 넘침 재측정 실측). .stage 자체를 클리핑 컨테이너로 만든다.
.stage { overflow: hidden; }
.toast {
position: relative;
box-sizing: border-box;
display: flex; align-items: flex-start; gap: $sp-3;
width: min(280px, 86vw);
padding: $sp-4 $sp-10 $sp-4 $sp-4;
border-radius: $r-card;
background: $subject-cream;
box-shadow: $shadow-raised;
transform: translateX(140%);
opacity: 0;
}
.toast__bar {
align-self: stretch;
width: $sp-1;
border-radius: $r-xs;
background: $color;
flex: none;
}
.toast__title { margin: 0 0 $sp-1; font-weight: 700; font-size: 15px; line-height: 1.3; font-family: inherit; color: $subject-ink; }
.toast__text { margin: 0; font-weight: 400; font-size: 13px; line-height: 1.4; font-family: inherit; color: $subject-ink; opacity: .78; }
.toast__close {
position: absolute; top: $sp-2; right: $sp-2;
display: grid; place-items: center;
width: $sp-6; height: $sp-6;
border: 0; border-radius: $r-xs;
background: transparent; color: $subject-ink; opacity: .55;
cursor: pointer;
&:hover, &:focus-visible { opacity: 1; }
}
// 실측 2026-09-10: 오른쪽 밖에서 들어와 머물다 다시 나간다. 한 바퀴 = 전역 루프(2s)
.toast.is-demo { animation: slide-loop $dur-loop $easing infinite; }
@keyframes slide-loop {
0% { transform: translateX(140%); opacity: 0; }
18% { transform: translateX(0); opacity: 1; }
78% { transform: translateX(0); opacity: 1; }
100% { transform: translateX(140%); opacity: 0; }
}
// ── 접근성: 움직임 줄이기 설정이면 자리만, 슬라이드는 생략 ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo { animation: none; transform: translateX(0); opacity: 1; }
}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 {
overflow: hidden;
}
.toast {
position: relative;
box-sizing: border-box;
display: flex;
align-items: flex-start;
gap: 12px;
width: min(280px, 86vw);
padding: 16px 40px 16px 16px;
border-radius: 16px;
background: #fff7e6;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
transform: translateX(140%);
opacity: 0;
}
.toast__bar {
align-self: stretch;
width: 4px;
border-radius: 4px;
background: #2f6df6;
flex: none;
}
.toast__title {
margin: 0 0 4px;
font-weight: 700;
font-size: 15px;
line-height: 1.3;
font-family: inherit;
color: #17141a;
}
.toast__text {
margin: 0;
font-weight: 400;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
color: #17141a;
opacity: 0.78;
}
.toast__close {
position: absolute;
top: 8px;
right: 8px;
display: grid;
place-items: center;
width: 24px;
height: 24px;
border: 0;
border-radius: 4px;
background: transparent;
color: #17141a;
opacity: 0.55;
cursor: pointer;
}
.toast__close:hover, .toast__close:focus-visible {
opacity: 1;
}
.toast.is-demo {
animation: slide-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes slide-loop {
0% {
transform: translateX(140%);
opacity: 0;
}
18% {
transform: translateX(0);
opacity: 1;
}
78% {
transform: translateX(0);
opacity: 1;
}
100% {
transform: translateX(140%);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo {
animation: none;
transform: translateX(0);
opacity: 1;
}
}import type { CSSProperties, ReactNode } from "react";
import styles from "./ToastSlideIn.module.scss";
export type ToastSlideInProps = {
visible: boolean;
title: string;
children: ReactNode;
onClose?: () => void;
/** 오른쪽에서 미끄러져 들어오는 시간 (기본 600ms) */
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function ToastSlideIn({
visible,
title,
children,
onClose,
duration = 600,
easing = "cubic-bezier(.2,.8,.2,1)",
color = "#2f6df6",
}: ToastSlideInProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={`${styles.toast} ${visible ? styles.isVisible : ""}`} style={vars} role="status" aria-live="polite">
<span className={styles.bar} aria-hidden="true" />
<div className={styles.body}>
<p className={styles.title}>{title}</p>
<p className={styles.text}>{children}</p>
</div>
<button className={styles.close} type="button" aria-label="알림 닫기" onClick={onClose}>
<svg viewBox="0 0 24 24" width={14} height={14} aria-hidden="true">
<line x1={5} y1={5} x2={19} y2={19} stroke="currentColor" strokeWidth={2.4} strokeLinecap="round" />
<line x1={19} y1={5} x2={5} y2={19} stroke="currentColor" strokeWidth={2.4} strokeLinecap="round" />
</svg>
</button>
</div>
);
}01 · 오른쪽 슬라이드 인 — 측정 누적면적 19.466% · 움직인 프레임 9/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코너 알림의 기본형
저장·업로드 완료처럼 코너에 붙는 알림에 가장 기본적으로 씁니다.
.toast {
position: relative;
transform: translateX(140%);
opacity: 0;
}
.toast.is-demo { animation: slide-loop $dur-loop $easing infinite; }
@keyframes slide-loop {
0% { transform: translateX(140%); opacity: 0; }
18% { transform: translateX(0); opacity: 1; }
78% { transform: translateX(0); opacity: 1; }
100% { transform: translateX(140%); opacity: 0; }
}
02Popover API 토스트
JS 없이 여닫는 속성
popover 속성과 popovertarget 버튼만으로 여닫혀, top-layer 스택과 ESC·바깥 클릭 닫기를 JS 없이 얻습니다.

<main class="stage">
<div class="demo">
<button class="opener" type="button" popovertarget="ptoast048">알림 다시 보기</button>
<div id="ptoast048" class="toast is-demo" popover role="status" aria-live="polite">
<span class="toast__dot" aria-hidden="true"></span>
<div class="toast__body">
<p class="toast__title">연결됨</p>
<p class="toast__text">네트워크가 복구되었습니다</p>
</div>
<button class="toast__close" type="button" popovertarget="ptoast048" popovertargetaction="hide" aria-label="알림 닫기">
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true">
<line x1="5" y1="5" x2="19" y2="19" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
<line x1="19" y1="5" x2="5" y2="19" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/>
</svg>
</button>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-base; // 300ms — 열리고 닫히는 속도
$easing: $ease-out;
$color: $subject-blue; // 상태 점 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-yellow);
.demo { display: grid; justify-items: center; gap: $sp-4; }
.opener {
border: 0; background: transparent;
color: $subject-ink; font-weight: 600; font-size: 13px; line-height: 1; font-family: inherit;
text-decoration: underline; text-underline-offset: $sp-1;
padding: $sp-2 $sp-1; cursor: pointer;
}
// popover 기본 스타일(테두리·배경·중앙 고정)을 지우고 화면 오른쪽 위 코너로
.toast[popover] {
position: fixed;
inset: unset;
top: $sp-4;
right: $sp-4;
margin: 0;
border: 0;
overflow: visible;
display: flex; align-items: flex-start; gap: $sp-3;
width: min(260px, 78vw);
padding: $sp-4 $sp-10 $sp-4 $sp-4;
border-radius: $r-card;
background: $subject-ink;
color: $subject-cream;
box-shadow: $shadow-raised;
}
.toast__dot {
align-self: center;
width: $sp-3; height: $sp-3;
border-radius: 50%;
background: $color;
flex: none;
}
.toast__title { margin: 0 0 $sp-1; font-weight: 700; font-size: 14px; line-height: 1.3; font-family: inherit; }
.toast__text { margin: 0; font-weight: 400; font-size: 13px; line-height: 1.4; font-family: inherit; opacity: .78; }
.toast__close {
position: absolute; top: $sp-2; right: $sp-2;
display: grid; place-items: center;
width: $sp-6; height: $sp-6;
border: 0; border-radius: $r-xs;
background: transparent; color: $subject-cream; opacity: .6;
cursor: pointer;
&:hover, &:focus-visible { opacity: 1; }
}
// 실측 2026-09-10: showPopover() 로 이미 열린 상태에서 등장→유지→살짝 접히는 루프를 계속 반복해
// "3초 뒤 자동으로 닫힌다"는 실제 동작을 무한 루프로 대신 보여준다 (전역 루프 2s)
.toast.is-demo { animation: pop-loop $dur-loop $easing infinite; }
@keyframes pop-loop {
0% { transform: translateY(-14px) scale(.92); opacity: 0; }
16% { transform: translateY(0) scale(1); opacity: 1; }
72% { transform: translateY(0) scale(1); opacity: 1; }
92% { transform: translateY(-6px) scale(.97); opacity: 0; }
100% { transform: translateY(-14px) scale(.92); opacity: 0; }
}
// ── 접근성: 움직임 줄이기 설정이면 뜬 채로 고정 ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo { animation: none; transform: none; opacity: 1; }
}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);
}
.demo {
display: grid;
justify-items: center;
gap: 16px;
}
.opener {
border: 0;
background: transparent;
color: #17141a;
font-weight: 600;
font-size: 13px;
line-height: 1;
font-family: inherit;
text-decoration: underline;
text-underline-offset: 4px;
padding: 8px 4px;
cursor: pointer;
}
.toast[popover] {
position: fixed;
inset: unset;
top: 16px;
right: 16px;
margin: 0;
border: 0;
overflow: visible;
display: flex;
align-items: flex-start;
gap: 12px;
width: min(260px, 78vw);
padding: 16px 40px 16px 16px;
border-radius: 16px;
background: #17141a;
color: #fff7e6;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.toast__dot {
align-self: center;
width: 12px;
height: 12px;
border-radius: 50%;
background: #2f6df6;
flex: none;
}
.toast__title {
margin: 0 0 4px;
font-weight: 700;
font-size: 14px;
line-height: 1.3;
font-family: inherit;
}
.toast__text {
margin: 0;
font-weight: 400;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
opacity: 0.78;
}
.toast__close {
position: absolute;
top: 8px;
right: 8px;
display: grid;
place-items: center;
width: 24px;
height: 24px;
border: 0;
border-radius: 4px;
background: transparent;
color: #fff7e6;
opacity: 0.6;
cursor: pointer;
}
.toast__close:hover, .toast__close:focus-visible {
opacity: 1;
}
.toast.is-demo {
animation: pop-loop 2s ease-out infinite;
}
@keyframes pop-loop {
0% {
transform: translateY(-14px) scale(0.92);
opacity: 0;
}
16% {
transform: translateY(0) scale(1);
opacity: 1;
}
72% {
transform: translateY(0) scale(1);
opacity: 1;
}
92% {
transform: translateY(-6px) scale(0.97);
opacity: 0;
}
100% {
transform: translateY(-14px) scale(0.92);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo {
animation: none;
transform: none;
opacity: 1;
}
}// popover 속성이 top-layer 스택·ESC 닫기·바깥 클릭 닫기를 공짜로 준다. 데모용으로 로드 즉시 한 번 연다.
document.getElementById('ptoast048').showPopover();import { useEffect, useRef } from "react";
import type { CSSProperties } from "react";
import styles from "./PopoverToast.module.scss";
export type PopoverToastProps = {
title: string;
message: string;
/** true 면 showPopover(), false 면 hidePopover() (기본 true) */
open?: boolean;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function PopoverToast({
title,
message,
open = true,
duration = 300,
easing = "ease-out",
color = "#2f6df6",
}: PopoverToastProps) {
const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
const el = ref.current as (HTMLDivElement & { showPopover?: () => void; hidePopover?: () => void }) | null;
if (!el) return;
if (open) el.showPopover?.();
else el.hidePopover?.();
}, [open]);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div ref={ref} popover="" className={styles.toast} style={vars} role="status" aria-live="polite">
<span className={styles.dot} aria-hidden="true" />
<div className={styles.body}>
<p className={styles.title}>{title}</p>
<p className={styles.text}>{message}</p>
</div>
</div>
);
}02 · Popover API 토스트 — 측정 누적면적 23.62% · 움직인 프레임 9/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
기본 위치를 덮어써야 하는 이유
기본 스타일이 화면 중앙 고정이라 코너 위치는 직접 덮어써야 합니다.
<div id="ptoast" class="toast" popover role="status" aria-live="polite">
<span class="toast__dot" aria-hidden="true"></span>
<p class="toast__title">연결됨</p>
<button popovertarget="ptoast" popovertargetaction="hide" aria-label="알림 닫기">
<svg viewBox="0 0 24 24" width="14" height="14"><line x1="5" y1="5" x2="19" y2="19"/><line x1="19" y1="5" x2="5" y2="19"/></svg>
</button>
</div>
<script>document.getElementById('ptoast').showPopover();</script>
033개 스택
토스트 알림 ui 를 덱으로 접어 두기
알림 3개가 평소엔 살짝 겹친 덱으로 접혀 있다가 hover나 focus 하면 부채꼴로 펼쳐져 각각 읽힙니다.

<main class="stage">
<div class="stack is-demo" tabindex="0" role="status" aria-live="polite" aria-label="알림 3개">
<div class="stack__item" style="--i:2">포인트가 적립되었습니다</div>
<div class="stack__item" style="--i:1">배송이 시작되었습니다</div>
<div class="stack__item" style="--i:0">결제가 완료되었습니다</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-base; // 300ms — 실제 hover/focus 로 펼쳐지는 속도
$easing: $ease-spring;
$color: $subject-cream; // 카드 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-orange);
.stack {
position: relative;
width: min(260px, 78vw);
height: 92px;
outline: none;
}
.stack__item {
position: absolute; inset: 0;
display: flex; align-items: center;
padding: $sp-4;
border-radius: $r-card;
background: $color;
color: $subject-ink;
font-weight: 600;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
box-shadow: $shadow-press;
// 뒤 카드일수록(--i 클수록) 더 밀리고 작아지고 흐려진다 — 평소엔 살짝 겹친 "덱" 모양
transform: translateY(calc(var(--i) * -6px)) scale(calc(1 - var(--i) * .05));
opacity: calc(1 - var(--i) * .22);
}
// 실제 사용: hover·focus 로 카드 3장을 부채꼴로 펼친다 (JS 없이)
.stack:hover .stack__item,
.stack:focus-within .stack__item {
transform: translateY(calc(var(--i) * -22px)) scale(1);
opacity: 1;
transition: transform $duration $easing, opacity $duration $easing;
}
// 실측 2026-09-10: 018 편의 "토스트 쌓임"(새 토스트가 올수록 기존 걸 밀어 올리는 큐)과 다르다 —
// 여기는 항상 3장이 고정으로 있고, 접힌 덱이 펼쳐졌다 다시 접히는 "카드 뭉치" 자체가 하나의 애니메이션이다.
.stack.is-demo .stack__item { animation: spread $dur-loop $easing infinite; }
@keyframes spread {
0%, 100% {
transform: translateY(calc(var(--i) * -6px)) scale(calc(1 - var(--i) * .05));
opacity: calc(1 - var(--i) * .22);
}
35%, 65% {
transform: translateY(calc(var(--i) * -22px)) scale(1);
opacity: 1;
}
}
// ── 접근성: 움직임 줄이기 설정이면 펼쳐진 채로 고정 ────────
@media (prefers-reduced-motion: reduce) {
.stack.is-demo .stack__item { animation: none; transform: translateY(calc(var(--i) * -22px)) scale(1); opacity: 1; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.stack {
position: relative;
width: min(260px, 78vw);
height: 92px;
outline: none;
}
.stack__item {
position: absolute;
inset: 0;
display: flex;
align-items: center;
padding: 16px;
border-radius: 16px;
background: #fff7e6;
color: #17141a;
font-weight: 600;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
transform: translateY(calc(var(--i) * -6px)) scale(calc(1 - var(--i) * 0.05));
opacity: calc(1 - var(--i) * 0.22);
}
.stack:hover .stack__item,
.stack:focus-within .stack__item {
transform: translateY(calc(var(--i) * -22px)) scale(1);
opacity: 1;
transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.stack.is-demo .stack__item {
animation: spread 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes spread {
0%, 100% {
transform: translateY(calc(var(--i) * -6px)) scale(calc(1 - var(--i) * 0.05));
opacity: calc(1 - var(--i) * 0.22);
}
35%, 65% {
transform: translateY(calc(var(--i) * -22px)) scale(1);
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.stack.is-demo .stack__item {
animation: none;
transform: translateY(calc(var(--i) * -22px)) scale(1);
opacity: 1;
}
}import type { CSSProperties } from "react";
import styles from "./ToastStack3.module.scss";
export type ToastStack3Props = {
/** 앞(맨 위)부터 순서대로 3개 */
items: [string, string, string];
color?: string;
duration?: number;
easing?: string;
};
type ItemVars = CSSProperties & { "--i"?: number };
export default function ToastStack3({
items,
color = "#fff7e6",
duration = 300,
easing = "cubic-bezier(.2,.8,.2,1)",
}: ToastStack3Props) {
const vars = { "--color": color, "--duration": `${duration}ms`, "--easing": easing } as CSSProperties;
const withIndex = items.map((text, i) => ({ text, i }));
const backToFront = [...withIndex].reverse(); // DOM은 뒤(i 큰 값)부터 써야 앞(i=0)이 맨 위에 그려진다
return (
<div
className={styles.stack}
style={vars}
tabIndex={0}
role="status"
aria-live="polite"
aria-label={`알림 ${items.length}개`}
>
{backToFront.map(({ text, i }) => {
const itemVars: ItemVars = { "--i": i };
return (
<div key={i} className={styles.item} style={itemVars}>
{text}
</div>
);
})}
</div>
);
}03 · 3개 스택 — 측정 누적면적 9.192% · 움직인 프레임 16/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
이벤트가 몰리는 알림함에
이벤트가 짧은 시간에 몰리는 대시보드 알림함에 어울립니다.
.stack__item {
position: absolute; inset: 0;
transform: translateY(calc(var(--i) * -6px))
scale(calc(1 - var(--i) * .05));
opacity: calc(1 - var(--i) * .22);
}
.stack:hover .stack__item,
.stack:focus-within .stack__item {
transform: translateY(calc(var(--i) * -22px)) scale(1);
opacity: 1;
transition: transform $duration $easing, opacity $duration $easing;
}
04남은 시간 바
바가 다 닳는 순간 사라진다
바닥의 진행바가 scaleX로 등속으로 줄어들다가 다 닳는 순간과 같은 타이밍에 토스트가 사라집니다.

<main class="stage">
<div class="toast is-demo" role="status" aria-live="polite">
<div class="toast__body">
<p class="toast__title">업로드 완료</p>
<p class="toast__text">5초 후 자동으로 닫힙니다</p>
</div>
<span class="toast__bar" aria-hidden="true"></span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: 5000ms; // 진행바가 다 닳아 닫히기까지 실제 시간 (UI 모션이 아니라 타이머 값이라 토큰 밖)
$easing: linear; // 진행바는 등속으로 — 급가속하면 "얼마 남았는지" 신뢰가 깨진다
$color: $subject-blue; // 진행바 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-paper);
.toast {
position: relative;
overflow: hidden;
width: min(280px, 84vw);
padding: $sp-4;
border-radius: $r-card;
background: $subject-ink;
color: $subject-cream;
box-shadow: $shadow-raised;
}
.toast__title { margin: 0 0 $sp-1; font-weight: 700; font-size: 15px; line-height: 1.3; font-family: inherit; }
.toast__text { margin: 0; font-weight: 400; font-size: 13px; line-height: 1.4; font-family: inherit; opacity: .78; }
.toast__bar {
position: absolute; left: 0; bottom: 0;
width: 100%; height: $sp-1;
background: $color;
transform-origin: left; // 규칙8: 진행바 왼쪽 끝 고정
transform: scaleX(1);
}
// 실제 사용: 진행바의 animationend 가 곧 닫힘 신호다. bar.addEventListener('animationend', () => toast.remove())
// 데모는 이 사이클(진행바가 다 닳고 → 토스트가 사라짐)을 전역 루프(2s) 안에 압축해 반복한다
.toast.is-demo .toast__bar { animation: bar-shrink $dur-loop $easing infinite; }
.toast.is-demo { animation: toast-out $dur-loop $ease-out infinite; }
@keyframes bar-shrink {
0% { transform: scaleX(1); }
82% { transform: scaleX(0); }
100% { transform: scaleX(0); }
}
@keyframes toast-out {
0%, 82% { opacity: 1; transform: translateY(0); }
100% { opacity: 0; transform: translateY(-8px); }
}
// ── 접근성: 움직임 줄이기 설정이면 진행바만 조용히 줄고 토스트는 안 흔들린다 ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo { animation: none; }
.toast.is-demo .toast__bar { animation: bar-shrink $duration linear forwards; }
}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);
}
.toast {
position: relative;
overflow: hidden;
width: min(280px, 84vw);
padding: 16px;
border-radius: 16px;
background: #17141a;
color: #fff7e6;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.toast__title {
margin: 0 0 4px;
font-weight: 700;
font-size: 15px;
line-height: 1.3;
font-family: inherit;
}
.toast__text {
margin: 0;
font-weight: 400;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
opacity: 0.78;
}
.toast__bar {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 4px;
background: #2f6df6;
transform-origin: left;
transform: scaleX(1);
}
.toast.is-demo .toast__bar {
animation: bar-shrink 2s linear infinite;
}
.toast.is-demo {
animation: toast-out 2s ease-out infinite;
}
@keyframes bar-shrink {
0% {
transform: scaleX(1);
}
82% {
transform: scaleX(0);
}
100% {
transform: scaleX(0);
}
}
@keyframes toast-out {
0%, 82% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(-8px);
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo {
animation: none;
}
.toast.is-demo .toast__bar {
animation: bar-shrink 5000ms linear forwards;
}
}import { useEffect, useRef } from "react";
import type { CSSProperties } from "react";
import styles from "./ProgressCloseToast.module.scss";
export type ProgressCloseToastProps = {
title: string;
message: string;
onDismiss?: () => void;
/** 진행바가 다 닳기까지 실제 시간 (기본 5000ms) */
duration?: number;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--color"?: string };
export default function ProgressCloseToast({
title,
message,
onDismiss,
duration = 5000,
color = "#2f6df6",
}: ProgressCloseToastProps) {
const barRef = useRef<HTMLSpanElement | null>(null);
useEffect(() => {
const bar = barRef.current;
if (!bar || !onDismiss) return;
const onEnd = () => onDismiss();
bar.addEventListener("animationend", onEnd);
return () => bar.removeEventListener("animationend", onEnd);
}, [onDismiss]);
const vars: Vars = { "--duration": `${duration}ms`, "--color": color };
return (
<div className={styles.toast} style={vars} role="status" aria-live="polite">
<div className={styles.body}>
<p className={styles.title}>{title}</p>
<p className={styles.text}>{message}</p>
</div>
<span ref={barRef} className={styles.bar} aria-hidden="true" />
</div>
);
}04 · 남은 시간 바 — 측정 누적면적 23.668% · 움직인 프레임 23/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
정해진 시간 뒤 닫히는 알림에
업로드·전송 완료처럼 정해진 시간 뒤 자동으로 닫혀야 하는 알림에 씁니다.
.toast__bar {
position: absolute; left: 0; bottom: 0;
width: 100%; height: 4px;
background: $color;
transform-origin: left;
}
.toast.is-demo .toast__bar { animation: bar-shrink $dur-loop linear infinite; }
@keyframes bar-shrink {
0% { transform: scaleX(1); }
82% { transform: scaleX(0); }
100% { transform: scaleX(0); }
}
05되돌리기 토스트
타이머를 멈추는 버튼
삭제 문구 옆 실행 취소 버튼을 누르면 타이머가 멈추고 문구가 취소됨으로 바뀌며, 누르지 않으면 위에서부터 접히며 사라집니다.

<main class="stage">
<div class="toast is-demo" role="status" aria-live="polite">
<p class="toast__text">항목을 삭제했습니다</p>
<button class="toast__undo" type="button">실행 취소</button>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-base; // 300ms — 접히며 사라지는 시간
$easing: $ease-out;
$color: $subject-blue-deep; // 실행 취소 글자 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-ink);
.toast {
box-sizing: border-box;
display: flex; align-items: center; justify-content: space-between; gap: $sp-4;
width: min(300px, 88vw);
padding: $sp-4;
border-radius: $r-card;
background: $subject-cream;
color: $subject-ink;
box-shadow: $shadow-raised;
transform-origin: top center; // 규칙8: 위 변에서 접혀 사라짐
}
.toast__text { margin: 0; font-weight: 600; font-size: 13px; line-height: 1.4; font-family: inherit; }
.toast__undo {
flex: none;
border: 0; background: transparent;
color: $color; font-weight: 700; font-size: 13px; line-height: 1; font-family: inherit;
padding: $sp-2 $sp-1;
cursor: pointer;
&:hover, &:focus-visible { text-decoration: underline; }
}
.toast.is-cancelled .toast__undo { visibility: hidden; }
// 실측 2026-09-10: 05번은 "실행취소" 버튼이 본체다. 데모는 등장 → 유지 → (취소 없이) 위에서부터 접히며 사라지는
// 한 바퀴를 반복한다 — scaleY 로 접는다(height 는 애니메이션하지 않는다, 원칙 1)
.toast.is-demo {
animation: undo-loop $dur-loop $easing infinite;
}
@keyframes undo-loop {
0% { transform: translateY(16px) scaleY(1); opacity: 0; }
15% { transform: translateY(0) scaleY(1); opacity: 1; }
70% { transform: translateY(0) scaleY(1); opacity: 1; }
92% { transform: translateY(0) scaleY(.35); opacity: .3; }
100% { transform: translateY(0) scaleY(0); opacity: 0; }
}
// ── 접근성: 움직임 줄이기 설정이면 접히지 않고 보이다 사라진다(opacity만) ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo { animation: none; transform: none; opacity: 1; }
}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);
}
.toast {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
width: min(300px, 88vw);
padding: 16px;
border-radius: 16px;
background: #fff7e6;
color: #17141a;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
transform-origin: top center;
}
.toast__text {
margin: 0;
font-weight: 600;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
}
.toast__undo {
flex: none;
border: 0;
background: transparent;
color: #0a4fe8;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
padding: 8px 4px;
cursor: pointer;
}
.toast__undo:hover, .toast__undo:focus-visible {
text-decoration: underline;
}
.toast.is-cancelled .toast__undo {
visibility: hidden;
}
.toast.is-demo {
animation: undo-loop 2s ease-out infinite;
}
@keyframes undo-loop {
0% {
transform: translateY(16px) scaleY(1);
opacity: 0;
}
15% {
transform: translateY(0) scaleY(1);
opacity: 1;
}
70% {
transform: translateY(0) scaleY(1);
opacity: 1;
}
92% {
transform: translateY(0) scaleY(0.35);
opacity: 0.3;
}
100% {
transform: translateY(0) scaleY(0);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo {
animation: none;
transform: none;
opacity: 1;
}
}// 실제 동작: 4초 뒤 사라지지만, 그 전에 "실행 취소"를 누르면 타이머를 멈추고 문구를 바꾼다
document.querySelectorAll('.toast').forEach(function (t) {
var btn = t.querySelector('.toast__undo'), msg = t.querySelector('.toast__text');
var timer = setTimeout(function () { t.classList.add('is-gone'); }, 4000);
btn.addEventListener('click', function () {
clearTimeout(timer);
msg.textContent = '취소되었습니다';
t.classList.add('is-cancelled');
});
});import { useCallback, useRef, useState } from "react";
import type { CSSProperties } from "react";
import styles from "./UndoToast.module.scss";
export type UndoToastProps = {
message: string;
undoLabel?: string;
cancelledMessage?: string;
onExpire?: () => void;
/** 몇 ms 뒤 자동으로 onExpire 를 부를지 (기본 4000ms) */
timeout?: number;
color?: string;
};
type Vars = CSSProperties & { "--color"?: string };
export default function UndoToast({
message,
undoLabel = "실행 취소",
cancelledMessage = "취소되었습니다",
onExpire,
timeout = 4000,
color = "#0a4fe8",
}: UndoToastProps) {
const [cancelled, setCancelled] = useState(false);
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
if (timer.current === null && onExpire) {
timer.current = setTimeout(onExpire, timeout);
}
const undo = useCallback(() => {
if (timer.current) clearTimeout(timer.current);
setCancelled(true);
}, []);
const vars: Vars = { "--color": color };
return (
<div className={styles.toast} style={vars} role="status" aria-live="polite">
<p className={styles.text}>{cancelled ? cancelledMessage : message}</p>
{!cancelled && (
<button className={styles.undo} type="button" onClick={undo}>
{undoLabel}
</button>
)}
</div>
);
}05 · 되돌리기 토스트 — 측정 누적면적 14.713% · 움직인 프레임 11/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
누르지 않으면 접히며 사라진다
리스트 항목 삭제 확인 대신 쓰기 좋습니다.
document.querySelectorAll('.toast').forEach(function (t) {
var btn = t.querySelector('.toast__undo'), msg = t.querySelector('.toast__text');
var timer = setTimeout(function () { t.classList.add('is-gone'); }, 4000);
btn.addEventListener('click', function () {
clearTimeout(timer);
msg.textContent = '취소되었습니다';
t.classList.add('is-cancelled');
});
});
06스와이프로 닫기
손가락을 따라 움직이는 카드
포인터를 누른 채 좌우로 끌면 손가락을 따라 카드가 움직이고, 80px 이상 밀고 떼면 그 방향으로 빠져나가며 닫힙니다.

<main class="stage">
<div class="toast is-demo" role="status" aria-live="polite">
<p class="toast__text">새 메시지가 도착했습니다</p>
<span class="toast__hint" aria-hidden="true">밀어서 닫기</span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-quick; // 220ms — 놓쳤을 때 닫히는 속도
$easing: $ease-out;
$color: $subject-ink; // 카드 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-yellow);
.toast {
position: relative;
display: flex; align-items: center; justify-content: space-between; gap: $sp-3;
width: min(280px, 84vw);
padding: $sp-4;
border-radius: $r-card;
background: $color;
color: $subject-cream;
box-shadow: $shadow-raised;
touch-action: pan-y; // 세로 스크롤은 살리고 가로만 드래그로 가져간다
transform: translateX(var(--dx, 0px));
}
.toast__text { margin: 0; font-weight: 600; font-size: 13px; line-height: 1.4; font-family: inherit; }
.toast__hint { flex: none; font-weight: 400; font-size: 11px; line-height: 1; font-family: inherit; opacity: .55; }
.toast.is-swiped-left,
.toast.is-swiped-right {
transition: transform $duration $easing, opacity $duration $easing;
opacity: 0;
}
.toast.is-swiped-left { transform: translateX(-120%); }
.toast.is-swiped-right { transform: translateX(120%); }
// 실측 2026-09-10: 손이 없는 렌더에서도 "밀려서 사라짐"이 보이게 자동 루프를 별도로 둔다
.toast.is-demo { animation: swipe-loop $dur-loop $easing infinite; }
@keyframes swipe-loop {
0% { transform: translateX(0); opacity: 0; }
10% { transform: translateX(0); opacity: 1; }
55% { transform: translateX(0); opacity: 1; }
85% { transform: translateX(120%); opacity: 0; }
86% { transform: translateX(0); opacity: 0; }
100% { transform: translateX(0); opacity: 0; }
}
// ── 접근성: 움직임 줄이기 설정이면 드래그 반응만 남기고 자동 루프는 끈다 ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo { animation: none; opacity: 1; transform: translateX(0); }
.toast.is-swiped-left, .toast.is-swiped-right { transition: opacity $duration linear; }
}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);
}
.toast {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
width: min(280px, 84vw);
padding: 16px;
border-radius: 16px;
background: #17141a;
color: #fff7e6;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
touch-action: pan-y;
transform: translateX(var(--dx, 0px));
}
.toast__text {
margin: 0;
font-weight: 600;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
}
.toast__hint {
flex: none;
font-weight: 400;
font-size: 11px;
line-height: 1;
font-family: inherit;
opacity: 0.55;
}
.toast.is-swiped-left,
.toast.is-swiped-right {
transition: transform 220ms ease-out, opacity 220ms ease-out;
opacity: 0;
}
.toast.is-swiped-left {
transform: translateX(-120%);
}
.toast.is-swiped-right {
transform: translateX(120%);
}
.toast.is-demo {
animation: swipe-loop 2s ease-out infinite;
}
@keyframes swipe-loop {
0% {
transform: translateX(0);
opacity: 0;
}
10% {
transform: translateX(0);
opacity: 1;
}
55% {
transform: translateX(0);
opacity: 1;
}
85% {
transform: translateX(120%);
opacity: 0;
}
86% {
transform: translateX(0);
opacity: 0;
}
100% {
transform: translateX(0);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo {
animation: none;
opacity: 1;
transform: translateX(0);
}
.toast.is-swiped-left, .toast.is-swiped-right {
transition: opacity 220ms linear;
}
}// 실제 동작: 손가락(또는 마우스)을 뗀 순간 80px 이상 밀렸으면 그 방향으로 닫힌다. 데모 루프는 놓고 자동 재생
(function () {
var el = document.querySelector('.toast'), x0 = 0, dx = 0, dragging = false;
el.addEventListener('pointerdown', function (e) { x0 = e.clientX; dragging = true; el.setPointerCapture(e.pointerId); el.classList.remove('is-demo'); });
el.addEventListener('pointermove', function (e) { if (!dragging) return; dx = e.clientX - x0; el.style.setProperty('--dx', dx + 'px'); });
el.addEventListener('pointerup', function () {
dragging = false;
if (Math.abs(dx) > 80) el.classList.add(dx > 0 ? 'is-swiped-right' : 'is-swiped-left');
else el.style.setProperty('--dx', '0px');
dx = 0;
});
})();import { useCallback, useRef, useState } from "react";
import type { CSSProperties, PointerEvent } from "react";
import styles from "./SwipeDismissToast.module.scss";
export type SwipeDismissToastProps = {
message: string;
hint?: string;
onDismiss?: (direction: "left" | "right") => void;
/** 이 px 이상 밀면 닫힌다 (기본 80) */
threshold?: number;
duration?: number;
color?: string;
};
type Vars = CSSProperties & { "--dx"?: string; "--color"?: string };
export default function SwipeDismissToast({
message,
hint = "밀어서 닫기",
onDismiss,
threshold = 80,
duration = 220,
color = "#17141a",
}: SwipeDismissToastProps) {
const [dx, setDx] = useState(0);
const [swiped, setSwiped] = useState<"left" | "right" | null>(null);
const x0 = useRef(0);
const dragging = useRef(false);
const onDown = useCallback((e: PointerEvent<HTMLDivElement>) => {
x0.current = e.clientX;
dragging.current = true;
e.currentTarget.setPointerCapture(e.pointerId);
}, []);
const onMove = useCallback((e: PointerEvent<HTMLDivElement>) => {
if (!dragging.current) return;
setDx(e.clientX - (x0.current ?? 0));
}, []);
const onUp = useCallback(() => {
dragging.current = false;
if (Math.abs(dx) > threshold) {
const dir = dx > 0 ? "right" : "left";
setSwiped(dir);
onDismiss?.(dir);
} else {
setDx(0);
}
}, [dx, threshold, onDismiss]);
const vars: Vars = { "--dx": `${swiped ? 0 : dx}px`, "--color": color };
return (
<div
className={`${styles.toast} ${swiped ? styles[swiped === "left" ? "swipedLeft" : "swipedRight"] : ""}`}
style={vars}
role="status"
aria-live="polite"
onPointerDown={onDown}
onPointerMove={onMove}
onPointerUp={onUp}
>
<p className={styles.text}>{message}</p>
<span className={styles.hint} aria-hidden="true">{hint}</span>
</div>
);
}06 · 스와이프로 닫기 — 측정 누적면적 20.664% · 움직인 프레임 9/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
80px 을 넘기면 닫힌다
터치 위주의 모바일 채팅·메신저 알림함에 맞는 방식입니다.
el.addEventListener('pointerdown', function (e) {
x0 = e.clientX; dragging = true; el.setPointerCapture(e.pointerId);
});
el.addEventListener('pointermove', function (e) {
if (!dragging) return;
dx = e.clientX - x0; el.style.setProperty('--dx', dx + 'px');
});
el.addEventListener('pointerup', function () {
dragging = false;
if (Math.abs(dx) > 80) el.classList.add(dx > 0 ? 'is-swiped-right' : 'is-swiped-left');
else el.style.setProperty('--dx', '0px');
});
07성공 아이콘
색 자체가 결과를 말한다
무채색 링 아이콘이 opacity로 사라지는 동시에 상태색 링과 체크가 겹쳐 드러나, 색 자체가 결과를 말합니다.
<main class="stage">
<div class="toast is-demo" role="status" aria-live="polite">
<span class="badge" aria-hidden="true">
<svg class="badge__layer badge__neutral" viewBox="0 0 24 24" width="28" height="28">
<circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="2"/>
</svg>
<svg class="badge__layer badge__colored" viewBox="0 0 24 24" width="28" height="28">
<circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="2"/>
<polyline class="badge__check" points="7 12.5 10.5 16 17 8.5" pathLength="100" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</span>
<div class="toast__body">
<p class="toast__title">결제 완료</p>
<p class="toast__text">카드 결제가 승인되었습니다</p>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개. $color 를 $error 로 바꾸면 "실패" 상태 아이콘이 된다 ──────────
$duration: $dur-base; // 300ms — 체크가 그려지는 시간대
$easing: $ease-out;
$color: $subject-blue; // 상태색. 성공은 blue, 변형에서 error 로
// ── 데모 무대 ───────────────────────────────
@include stage($stage-orange);
.toast {
display: flex; align-items: center; gap: $sp-3;
width: min(280px, 84vw);
padding: $sp-4;
border-radius: $r-card;
background: $subject-cream;
color: $subject-ink;
box-shadow: $shadow-raised;
}
.badge { position: relative; display: grid; place-items: center; width: 28px; height: 28px; flex: none; }
.badge__layer { grid-area: 1 / 1; }
.badge__neutral { color: $subject-ink; opacity: .3; }
.badge__colored { color: $color; opacity: 0; }
.badge__check { stroke-dasharray: 100; stroke-dashoffset: 100; }
.toast__title { margin: 0 0 $sp-1; font-weight: 700; font-size: 15px; line-height: 1.3; font-family: inherit; }
.toast__text { margin: 0; font-weight: 400; font-size: 13px; line-height: 1.4; font-family: inherit; opacity: .78; }
// 실측 2026-09-10: 018 편 "저장 체크"(디스켓→체크 clip-path 모프)와도, 031 편 "읽음 표시"(숫자→체크 opacity·scale)와도 다르다.
// 여기는 두 아이콘 레이어(무채색 링 / 상태색 링+체크)가 opacity 로 겹쳐 바뀌면서 "상태색이 곧 결과"라는 걸 보여준다.
.toast.is-demo {
.badge__neutral { animation: fade-out $dur-loop $easing infinite; }
.badge__colored { animation: fade-in $dur-loop $easing infinite; }
.badge__check { animation: draw $dur-loop $easing infinite; }
}
@keyframes fade-out {
0%, 15% { opacity: .3; }
32%, 80% { opacity: 0; }
95%, 100% { opacity: .3; }
}
@keyframes fade-in {
0%, 15% { opacity: 0; }
32%, 80% { opacity: 1; }
95%, 100% { opacity: 0; }
}
@keyframes draw {
0%, 22% { stroke-dashoffset: 100; }
55%, 100% { stroke-dashoffset: 0; }
}
// ── 접근성: 움직임 줄이기 설정이면 완성된 상태색 체크만 남긴다 ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo .badge__neutral { animation: none; opacity: 0; }
.toast.is-demo .badge__colored { animation: none; opacity: 1; }
.toast.is-demo .badge__check { 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: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.toast {
display: flex;
align-items: center;
gap: 12px;
width: min(280px, 84vw);
padding: 16px;
border-radius: 16px;
background: #fff7e6;
color: #17141a;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.badge {
position: relative;
display: grid;
place-items: center;
width: 28px;
height: 28px;
flex: none;
}
.badge__layer {
grid-area: 1/1;
}
.badge__neutral {
color: #17141a;
opacity: 0.3;
}
.badge__colored {
color: #2f6df6;
opacity: 0;
}
.badge__check {
stroke-dasharray: 100;
stroke-dashoffset: 100;
}
.toast__title {
margin: 0 0 4px;
font-weight: 700;
font-size: 15px;
line-height: 1.3;
font-family: inherit;
}
.toast__text {
margin: 0;
font-weight: 400;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
opacity: 0.78;
}
.toast.is-demo .badge__neutral {
animation: fade-out 2s ease-out infinite;
}
.toast.is-demo .badge__colored {
animation: fade-in 2s ease-out infinite;
}
.toast.is-demo .badge__check {
animation: draw 2s ease-out infinite;
}
@keyframes fade-out {
0%, 15% {
opacity: 0.3;
}
32%, 80% {
opacity: 0;
}
95%, 100% {
opacity: 0.3;
}
}
@keyframes fade-in {
0%, 15% {
opacity: 0;
}
32%, 80% {
opacity: 1;
}
95%, 100% {
opacity: 0;
}
}
@keyframes draw {
0%, 22% {
stroke-dashoffset: 100;
}
55%, 100% {
stroke-dashoffset: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo .badge__neutral {
animation: none;
opacity: 0;
}
.toast.is-demo .badge__colored {
animation: none;
opacity: 1;
}
.toast.is-demo .badge__check {
animation: none;
stroke-dashoffset: 0;
}
}import type { CSSProperties } from "react";
import styles from "./StatusIconToast.module.scss";
export type StatusIconToastProps = {
title: string;
message: string;
/** 상태색. 성공은 파랑, 실패는 error 색을 넘긴다 */
color?: string;
resolved?: boolean;
};
type Vars = CSSProperties & { "--color"?: string };
export default function StatusIconToast({
title,
message,
color = "#2f6df6",
resolved = true,
}: StatusIconToastProps) {
const vars: Vars = { "--color": color };
return (
<div className={styles.toast} style={vars} role="status" aria-live="polite">
<span className={styles.badge} aria-hidden="true">
<svg className={`${styles.layer} ${styles.neutral}`} viewBox="0 0 24 24" width={28} height={28} style={{ opacity: resolved ? 0 : 0.3 }}>
<circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" strokeWidth={2} />
</svg>
<svg className={`${styles.layer} ${styles.colored}`} viewBox="0 0 24 24" width={28} height={28} style={{ opacity: resolved ? 1 : 0 }}>
<circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" strokeWidth={2} />
<polyline
className={styles.check}
points="7 12.5 10.5 16 17 8.5"
pathLength={100}
fill="none"
stroke="currentColor"
strokeWidth={2.6}
strokeLinecap="round"
strokeLinejoin="round"
style={{ strokeDashoffset: resolved ? 0 : 100 }}
/>
</svg>
</span>
<div className={styles.body}>
<p className={styles.title}>{title}</p>
<p className={styles.text}>{message}</p>
</div>
</div>
);
}07 · 성공 아이콘 — 측정 누적면적 0.215% · 움직인 프레임 14/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
실패 배지로 바꾸는 법
$color를 error 색으로 바꾸면 그대로 실패 배지가 됩니다.
.badge__neutral { opacity: .3; }
.badge__colored { opacity: 0; }
.badge__check { stroke-dasharray: 100; stroke-dashoffset: 100; }
.toast.is-demo .badge__neutral { animation: fade-out $dur-loop $easing infinite; }
.toast.is-demo .badge__colored { animation: fade-in $dur-loop $easing infinite; }
.toast.is-demo .badge__check { animation: draw $dur-loop $easing infinite; }
08모바일 하단 토스트
안전영역을 피해 올라오는 알약
화면 하단에 고정된 알약형 바가 안전영역을 피해 위로 살짝 올라왔다가 다시 내려갑니다.

<main class="stage">
<div class="toast is-demo" role="status" aria-live="polite">
<p class="toast__text">새 소식이 도착했습니다</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-enter; // 600ms — 아래에서 올라오는 시간
$easing: $ease-spring;
$color: $subject-blue; // 글자 대비용 참고색(테두리 없음, 변형에서 강조선에 쓴다)
// ── 데모 무대 ───────────────────────────────
@include stage($stage-paper);
// 모바일 하단 고정 스트립 — 03 편의 bottom-sheet(손잡이 달린 큰 패널)와 달리
// 한 줄짜리 알약형이고 안전영역을 고려해 자동으로 사라진다 (모달이 아니라 알림이다)
.toast {
position: fixed;
left: $sp-4; right: $sp-4;
bottom: calc(env(safe-area-inset-bottom, 0px) + #{$sp-4});
margin: 0 auto;
max-width: 340px;
padding: $sp-3 $sp-5;
border-radius: $r-pill;
background: $subject-ink;
color: $subject-cream;
box-shadow: $shadow-raised;
text-align: center;
transform: translateY(140%);
opacity: 0;
}
.toast__text { margin: 0; font-weight: 600; font-size: 13px; line-height: 1.4; font-family: inherit; }
.toast.is-demo { animation: bottom-loop $dur-loop $easing infinite; }
@keyframes bottom-loop {
0% { transform: translateY(140%); opacity: 0; }
20% { transform: translateY(0); opacity: 1; }
78% { transform: translateY(0); opacity: 1; }
100% { transform: translateY(140%); opacity: 0; }
}
// ── 접근성: 움직임 줄이기 설정이면 뜬 채로 고정 ────────
@media (prefers-reduced-motion: reduce) {
.toast.is-demo { animation: none; transform: translateY(0); opacity: 1; }
}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);
}
.toast {
position: fixed;
left: 16px;
right: 16px;
bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
margin: 0 auto;
max-width: 340px;
padding: 12px 20px;
border-radius: 999px;
background: #17141a;
color: #fff7e6;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
text-align: center;
transform: translateY(140%);
opacity: 0;
}
.toast__text {
margin: 0;
font-weight: 600;
font-size: 13px;
line-height: 1.4;
font-family: inherit;
}
.toast.is-demo {
animation: bottom-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes bottom-loop {
0% {
transform: translateY(140%);
opacity: 0;
}
20% {
transform: translateY(0);
opacity: 1;
}
78% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(140%);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.toast.is-demo {
animation: none;
transform: translateY(0);
opacity: 1;
}
}import type { CSSProperties } from "react";
import styles from "./BottomMobileToast.module.scss";
export type BottomMobileToastProps = {
message: string;
visible: boolean;
duration?: number;
easing?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string };
export default function BottomMobileToast({
message,
visible,
duration = 600,
easing = "cubic-bezier(.2,.8,.2,1)",
}: BottomMobileToastProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing };
return (
<div className={`${styles.toast} ${visible ? styles.isVisible : ""}`} style={vars} role="status" aria-live="polite">
<p className={styles.text}>{message}</p>
</div>
);
}08 · 모바일 하단 토스트 — 측정 누적면적 15.832% · 움직인 프레임 9/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
바텀시트와 다른 점
손잡이 달린 바텀시트와 달리 한 줄만 보여주고 자동으로 닫힙니다.
.toast {
position: fixed;
left: 16px; right: 16px;
bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
margin: 0 auto;
max-width: 340px;
border-radius: 999px;
transform: translateY(140%);
opacity: 0;
}
.toast.is-demo { animation: bottom-loop $dur-loop $easing infinite; }
09알림 배지
종과 배지가 같은 타이밍에
종 아이콘이 꼭짓점을 축으로 짧게 흔들리는 동시에 오른쪽 위 배지가 확대·축소되며 새 알림이 왔다는 한 순간을 만듭니다.

<main class="stage">
<button class="bell is-demo" type="button" aria-label="알림 3개">
<svg viewBox="0 0 24 24" width="32" height="32" aria-hidden="true">
<g class="bell__body">
<path d="M12 3a5 5 0 0 0-5 5v3.2c0 .9-.35 1.77-.98 2.4L5 15h14l-1.02-1.4a3.4 3.4 0 0 1-.98-2.4V8a5 5 0 0 0-5-5Z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>
<path d="M10 18a2 2 0 0 0 4 0" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
</g>
</svg>
<span class="badge" aria-hidden="true">3</span>
</button>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────
$duration: $dur-base; // 300ms — 종이 흔들리는 시간
$easing: $ease-out;
$color: $subject-blue; // 배지 색
// ── 데모 무대 ───────────────────────────────
@include stage($stage-ink);
.bell {
position: relative;
display: grid; place-items: center;
width: 56px; height: 56px;
border: 0; border-radius: $r-control;
background: transparent;
color: $subject-cream;
cursor: pointer;
&:hover, &:focus-visible { background: rgba(255, 255, 255, .08); }
}
.bell__body {
transform-box: fill-box;
transform-origin: 50% 0%; // 종의 꼭지점을 축으로 흔든다
}
.badge {
position: absolute; top: $sp-1; right: $sp-1;
display: grid; place-items: center;
min-width: 18px; height: 18px;
padding: 0 $sp-1;
border-radius: $r-pill;
background: $color;
color: #fff;
font-weight: 700;
font-size: 10px;
line-height: 1;
font-family: inherit;
}
// 실측 2026-09-10: 흔들림과 배지 맥동을 같은 구간에 겹쳐 "새 알림이 왔다"는 한 순간을 만든다
.bell.is-demo .bell__body { animation: shake $dur-loop $easing infinite; }
.bell.is-demo .badge { animation: pulse $dur-loop $easing infinite; }
@keyframes shake {
0%, 55%, 100% { transform: rotate(0deg); }
60% { transform: rotate(-14deg); }
65% { transform: rotate(12deg); }
70% { transform: rotate(-8deg); }
75% { transform: rotate(5deg); }
80% { transform: rotate(0deg); }
}
@keyframes pulse {
0%, 55%, 100% { transform: scale(1); }
60% { transform: scale(1.3); }
70% { transform: scale(1); }
}
// ── 접근성: 움직임 줄이기 설정이면 흔들지 않고 배지만 남긴다 ────────
@media (prefers-reduced-motion: reduce) {
.bell.is-demo .bell__body { animation: none; }
.bell.is-demo .badge { 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);
}
.bell {
position: relative;
display: grid;
place-items: center;
width: 56px;
height: 56px;
border: 0;
border-radius: 12px;
background: transparent;
color: #fff7e6;
cursor: pointer;
}
.bell:hover, .bell:focus-visible {
background: rgba(255, 255, 255, 0.08);
}
.bell__body {
transform-box: fill-box;
transform-origin: 50% 0%;
}
.badge {
position: absolute;
top: 4px;
right: 4px;
display: grid;
place-items: center;
min-width: 18px;
height: 18px;
padding: 0 4px;
border-radius: 999px;
background: #2f6df6;
color: #fff;
font-weight: 700;
font-size: 10px;
line-height: 1;
font-family: inherit;
}
.bell.is-demo .bell__body {
animation: shake 2s ease-out infinite;
}
.bell.is-demo .badge {
animation: pulse 2s ease-out infinite;
}
@keyframes shake {
0%, 55%, 100% {
transform: rotate(0deg);
}
60% {
transform: rotate(-14deg);
}
65% {
transform: rotate(12deg);
}
70% {
transform: rotate(-8deg);
}
75% {
transform: rotate(5deg);
}
80% {
transform: rotate(0deg);
}
}
@keyframes pulse {
0%, 55%, 100% {
transform: scale(1);
}
60% {
transform: scale(1.3);
}
70% {
transform: scale(1);
}
}
@media (prefers-reduced-motion: reduce) {
.bell.is-demo .bell__body {
animation: none;
}
.bell.is-demo .badge {
animation: none;
}
}import type { CSSProperties } from "react";
import styles from "./BellBadge.module.scss";
export type BellBadgeProps = {
count: number;
onClick?: () => void;
color?: string;
};
type Vars = CSSProperties & { "--color"?: string };
export default function BellBadge({ count, onClick, color = "#2f6df6" }: BellBadgeProps) {
const vars: Vars = { "--color": color };
return (
<button className={styles.bell} style={vars} type="button" aria-label={`알림 ${count}개`} onClick={onClick}>
<svg viewBox="0 0 24 24" width={32} height={32} aria-hidden="true">
<g className={styles.body}>
<path
d="M12 3a5 5 0 0 0-5 5v3.2c0 .9-.35 1.77-.98 2.4L5 15h14l-1.02-1.4a3.4 3.4 0 0 1-.98-2.4V8a5 5 0 0 0-5-5Z"
fill="none"
stroke="currentColor"
strokeWidth={1.8}
strokeLinejoin="round"
/>
<path d="M10 18a2 2 0 0 0 4 0" fill="none" stroke="currentColor" strokeWidth={1.8} strokeLinecap="round" />
</g>
</svg>
{count > 0 && (
<span className={styles.badge} aria-hidden="true">
{count}
</span>
)}
</button>
);
}09 · 알림 배지 — 측정 누적면적 0.469% · 움직인 프레임 8/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
헤더의 읽지 않은 수에
헤더의 읽지 않은 메시지 수 표시에 씁니다.
.bell__body {
transform-box: fill-box;
transform-origin: 50% 0%;
}
.bell.is-demo .bell__body { animation: shake $dur-loop $easing infinite; }
.bell.is-demo .badge { animation: pulse $dur-loop $easing infinite; }
@keyframes shake {
0%, 55%, 100% { transform: rotate(0deg); }
60% { transform: rotate(-14deg); }
65% { transform: rotate(12deg); }
70% { transform: rotate(-8deg); }
}
어디서 깨지는가 — 함정 하나
왜 transform 과 opacity 만 쓰나
아홉 개가 전부 transform과 opacity만 움직이는 이유는 같습니다. width나 top을 애니메이션하면 브라우저가 매 프레임 레이아웃을 다시 계산하기 때문입니다. 그런데 레이어를 겹치는 항목에서 다른 함정을 하나 만났습니다. 07 성공 아이콘은 무채색 링과 상태색 링, 두 개의 SVG를 같은 자리에 겹쳐 opacity로 바꿔치기하는데, 두 레이어에 grid-area: 1 / 1을 안 주면 세로로 나란히 쌓여 배지 전체 높이가 두 배로 늘어납니다. 03 3개 스택도 비슷한 함정이 있습니다. 카드마다 --i 값을 style.scss 안에 고정으로 적으면 세 장이 똑같은 값을 받아 완전히 겹쳐 보이므로, 반드시 style="--i:0"처럼 요소마다 인라인으로 다르게 줘야 합니다.
그림자까지 밀어내야 한다
01 오른쪽 슬라이드 인은 translateX(100%)가 아니라 140%를 씁니다. 카드에 box-shadow가 붙어 있어서, 카드 폭만큼만 밀어내면 그림자 끄트머리가 화면 오른쪽 경계에 아직 걸쳐 보이기 때문입니다.
기본값을 믿으면 걸리는 곳
아직 그려지는 중인 화면에 알림이 끼어드는 사고는 히어로 섹션 애니메이션처럼 첫 등장 연출이 긴 페이지에서 특히 잦습니다.
02 Popover API 토스트에서도 한 번 걸렸습니다. popover 속성의 기본 UA 스타일은 화면 가운데 고정이라, position: fixed와 top·right·margin을 전부 덮어쓰지 않으면 코너가 아니라 한가운데 떠 버립니다. Chrome·Edge 114+, Safari 17+, Firefox 125+에서 Popover API를 쓸 수 있고(caniuse), 그보다 오래된 브라우저에서는 popover 속성 자체가 무시되면서 평범한 <div>로 남기 때문에 별도 JS로 보이기·숨기기를 대신 걸어야 합니다. 08 모바일 하단 토스트에서 쓴 env(safe-area-inset-bottom)도 마찬가지로, iOS Safari 11.2+부터(caniuse) 실제 노치·홈 인디케이터 값을 돌려주고, 그 기능이 없는 브라우저에서는 calc()의 폴백값 0px이 조용히 적용됩니다. 06 스와이프로 닫기에서는 pointerdown 때 setPointerCapture를 걸지 않으면 손가락이 카드 경계를 벗어나는 순간 pointermove가 끊겨 드래그가 그대로 멈췄습니다. grid-area 하나, 인라인 --i 하나, 방금 나온 setPointerCapture 하나까지 세 군데를 다 고쳐서 렌더 측정까지 다시 돌려 둔 zip을 열 때 넣을 문자열은 vp67sjt7이며, 아래 버튼을 누르면 내려받을 수 있습니다.
접근성
polite 와 assertive 사이
아홉 개 전부 role="status" aria-live="polite"를 썼습니다. 화면을 읽는 사람에게는 알리되 지금 하던 일을 멈추게 하진 않는 수준이라서입니다. 로그인 실패처럼 사용자의 응답이 꼭 필요한 알림이라면 aria-live="assertive"로 올려 즉시 끼어들게 해야 합니다. 04 남은 시간 바처럼 스스로 닫히는 항목은 WCAG 2.2.1 Timing Adjustable이 시간 제한을 늘리거나 끌 방법을 요구합니다. 이 글의 04는 5초라는 최소 시간만 두었으므로, 실제로 쓸 때는 05처럼 실행 취소 버튼을 같이 둬서 타이머를 멈출 길을 마련해야 합니다. prefers-reduced-motion: reduce에서는 대부분 슬라이드·회전·펼침 애니메이션을 껐지만, 04의 진행바만은 예외로 남겼습니다. 진행바가 언제 닫힐지 알려 주는 기능적인 정보이지 장식이 아니기 때문입니다. prefers-reduced-motion이 정확히 어떤 값을 받고 어떻게 켜지는지는 MDN 문서에 정리돼 있습니다.
이어서 볼 글
018편 바이브코딩 마이크로 인터랙션의 토스트 쌓임은 새 토스트가 올 때마다 기존 걸 밀어 올리는 큐라서, 여기 03 3개 스택(고정된 덱이 hover로 펼쳐지는 정적 스택)과는 방향이 반대입니다. 003편 모달 애니메이션의 바텀 시트도 손잡이 달린 큰 패널이라, 한 줄짜리 알약형이 안전영역을 피해 자동으로 닫히는 08 모바일 하단 토스트와는 쓰임이 다릅니다. 이 사이트의 다른 CSS 애니메이션 글은 카테고리 목록에서 훑어볼 수 있고, 무엇을 만드는 곳인지는 소개 페이지에 적어 뒀습니다.
FAQ
토스트는 role="status"인가요, role="alert"인가요?
대부분의 토스트는 role="status" aria-live="polite"가 맞습니다. role="alert"(또는 aria-live="assertive")는 화면 읽기를 즉시 끊고 끼어드는 강도라서, 결제 실패나 세션 만료처럼 사용자가 반드시 지금 알아야 하는 알림에만 씁니다.
토스트 애니메이션이 자동으로 닫히는 시간은 몇 초가 적당한가요?
정해진 답은 없지만 WCAG 2.2.1은 시간 제한을 늘리거나 끌 방법을 요구합니다. 이 글의 04는 5초를 기본값으로 두었을 뿐이므로, 실제로 쓸 때는 05처럼 실행 취소나 일시정지 버튼을 같이 둬서 다 읽기 전에 사라지는 상황을 막아야 합니다.
Popover API를 아직 못 쓰는 브라우저는 어떻게 하나요?
popover 속성이 없는 브라우저에서는 그냥 평범한 <div>로 남으므로, if ('showPopover' in document.createElement('div'))로 지원 여부를 확인하고 지원하지 않을 때만 직접 클래스 토글로 열고 닫는 JS를 추가하면 됩니다. 알림이 여러 장 쌓일 때의 순서와 밀림은 토스트 알림 UI 스택에서 따로 다룹니다.









