08한정 수량 재고바 뱃지
뱃지 안에 붙인 얇은 막대가 transform-origin: left 로 scaleX 를 1에서 0.25 까지 줄이며, 동시에 배경색이 초록에서 주황·빨강으로 보간돼 재고가 줄어드는 걸 색과 길이로 같이 보여준다.
쓰임품절 임박 상품의 재고 경고, 한정판·선착순 구매 유도
scaleX draintransform-origin: left배경색 다단 보간

<main class="stage is-demo">
<div class="badge" aria-label="3 left in stock">
<span class="label">3 LEFT</span>
<span class="track"><span class="fill"></span></span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-loop; // 2s — 재고바가 줄어드는 한 주기
$easing: $ease-out;
$color: #50a26e; // 재고 넉넉함(시작 색)
@include stage($stage-paper);
.badge {
width: 148px;
padding: $sp-3 $sp-4;
border-radius: $r-card;
background: $subject-ink;
box-shadow: $shadow-raised;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
.label {
display: block;
margin-bottom: $sp-2;
color: #fff;
font-weight: 700;
font-size: 15px;
letter-spacing: .04em;
}
.track {
display: block;
width: 100%; height: $sp-2;
border-radius: $r-xs;
background: rgba(255, 255, 255, .15);
overflow: hidden;
}
.fill {
display: block;
width: 100%; height: 100%;
border-radius: $r-xs;
background: $color;
transform: scaleX(1);
transform-origin: left; // 규칙8: 재고게이지 left 기준
}
.stage.is-demo .fill {
animation: drain $duration $easing infinite;
}
@keyframes drain {
0%, 10% { transform: scaleX(1); background: $color; }
50% { transform: scaleX(.6); background: $stage-orange; }
90%, 100% { transform: scaleX(.25); background: $error; }
}
@media (prefers-reduced-motion: reduce) {
.stage.is-demo .fill { animation: none; transform: scaleX(.25); background: $error; }
}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);
}
.badge {
width: 148px;
padding: 12px 16px;
border-radius: 16px;
background: #17141a;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
.label {
display: block;
margin-bottom: 8px;
color: #fff;
font-weight: 700;
font-size: 15px;
letter-spacing: 0.04em;
}
.track {
display: block;
width: 100%;
height: 8px;
border-radius: 4px;
background: rgba(255, 255, 255, 0.15);
overflow: hidden;
}
.fill {
display: block;
width: 100%;
height: 100%;
border-radius: 4px;
background: #50a26e;
transform: scaleX(1);
transform-origin: left;
}
.stage.is-demo .fill {
animation: drain 2s ease-out infinite;
}
@keyframes drain {
0%, 10% {
transform: scaleX(1);
background: #50a26e;
}
50% {
transform: scaleX(0.6);
background: #ff4d1f;
}
90%, 100% {
transform: scaleX(0.25);
background: #c2361a;
}
}
@media (prefers-reduced-motion: reduce) {
.stage.is-demo .fill {
animation: none;
transform: scaleX(0.25);
background: #c2361a;
}
}import type { CSSProperties } from "react";
import styles from "./BadgeLimitedStock.module.scss";
export type BadgeLimitedStockProps = {
duration?: number;
easing?: string;
color?: string;
left?: number;
};
export default function BadgeLimitedStock({
duration = 2000,
easing = "ease-out",
color = "#16a34a",
left = 3,
}: BadgeLimitedStockProps) {
const vars: CSSProperties = { "--duration": `${duration}ms`, "--easing": easing, "--color": color } as CSSProperties;
return (
<div className={styles.badge} style={vars} aria-label={`${left} left in stock`}>
<span className={styles.label}>{left} LEFT</span>
<span className={styles.track}>
<span className={styles.fill} />
</span>
</div>
);
}08 한정 수량 재고바 뱃지 — 측정 누적면적 0.817% · 움직인 프레임 20/23GODRICH 원작 · zip 에 SCSS·React 포함 · 뱃지 디자인 UI 9종 — 신상·세일·인증 배지 코드
이 데모가 속한 글
뱃지 디자인 UI 9종 — 신상·세일·인증 배지 코드뱃지 디자인 UI는 상품 썸네일이나 이름 옆에 작게 붙어 지금 상태를 알려주는 라벨 장식이다. NEW·세일·인증·품절처럼 사진 없이 코드 몇 줄로 만들 수 있고, 움직임 하나만 더하면 복붙 몇 줄로도 훨씬 눈에 띈다 이 글의 데모 전부 보기


