04통화 기호 붙은 금액 카운트업
숫자 앞뒤에 ::before·::after 로 통화 기호를 붙이고, 자릿수가 커지는 동안 기호는 고정된 자리를 지킨다.
쓰임가격 강조, 할인 금액, 결제 총액 요약
::before content통화 기호 고정$dur-enter

<main class="stage">
<div class="counter is-demo">
<span class="counter__num" aria-hidden="true"></span>
<span class="counter__sr">$248</span>
<span class="counter__label">결제 금액</span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-enter;
$easing: $ease-out;
$color: $subject-blue;
@include stage($stage-paper);
@property --num {
syntax: '<integer>';
initial-value: 0;
inherits: false;
}
.counter {
text-align: left; // 자릿수가 늘어도 통화 기호가 같은 자리를 지킨다
&__num {
--num: 0;
counter-reset: num var(--num);
display: inline-flex;
align-items: baseline;
font-weight: 800; font-size: clamp(34px, 10vw, 56px); line-height: 1; font-family: inherit;
font-variant-numeric: tabular-nums;
color: $color;
// 통화 기호는 고정 텍스트 — 숫자만 애니메이션한다
&::before { content: "$"; margin-right: 2px; }
&::after { content: counter(num); }
}
&__sr {
position: absolute;
width: 1px; height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
&__label {
display: block;
margin-top: clamp(6px, 2vw, 10px);
font-weight: 600; font-size: clamp(12px, 3.4vw, 15px); line-height: 1; font-family: inherit;
color: rgba(23, 20, 26, .6);
}
}
.counter.is-demo .counter__num {
animation: currency-up $duration $easing infinite;
}
@keyframes currency-up {
0% { --num: 0; }
55% { --num: 248; }
100% { --num: 248; }
}
@media (prefers-reduced-motion: reduce) {
.counter.is-demo .counter__num { animation: none; --num: 248; }
}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);
}
@property --num {
syntax: "<integer>";
initial-value: 0;
inherits: false;
}
.counter {
text-align: left;
}
.counter__num {
--num: 0;
counter-reset: num var(--num);
display: inline-flex;
align-items: baseline;
font-weight: 800;
font-size: clamp(34px, 10vw, 56px);
line-height: 1;
font-family: inherit;
font-variant-numeric: tabular-nums;
color: #2f6df6;
}
.counter__num::before {
content: "$";
margin-right: 2px;
}
.counter__num::after {
content: counter(num);
}
.counter__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.counter__label {
display: block;
margin-top: clamp(6px, 2vw, 10px);
font-weight: 600;
font-size: clamp(12px, 3.4vw, 15px);
line-height: 1;
font-family: inherit;
color: rgba(23, 20, 26, 0.6);
}
.counter.is-demo .counter__num {
animation: currency-up 600ms ease-out infinite;
}
@keyframes currency-up {
0% {
--num: 0;
}
55% {
--num: 248;
}
100% {
--num: 248;
}
}
@media (prefers-reduced-motion: reduce) {
.counter.is-demo .counter__num {
animation: none;
--num: 248;
}
}import type { CSSProperties } from "react";
import styles from "./CurrencyFormatCounter.module.scss";
export type CurrencyFormatCounterProps = {
value: number;
label: string;
symbol?: string;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string; "--num-target"?: number };
export default function CurrencyFormatCounter({
value, label, symbol = "$", duration = 600, easing = "ease-out", color = "#2f6df6",
}: CurrencyFormatCounterProps) {
const vars: Vars = {
"--duration": `${duration}ms`,
"--easing": easing,
"--color": color,
"--num-target": value,
};
return (
<div className={styles.counter} style={vars}>
<span className={styles.num} aria-hidden="true">
<span className={styles.symbol}>{symbol}</span>
</span>
<span className={styles.sr}>{symbol}{value.toLocaleString()}</span>
<span className={styles.label}>{label}</span>
</div>
);
}04 통화 기호 붙은 금액 카운트업 — 측정 누적면적 3.635% · 움직인 프레임 16/23GODRICH 원작 · zip 에 SCSS·React 포함 · CSS 숫자 증가 애니메이션 9종 — 한 줄 복붙으로
이 데모가 속한 글
CSS 숫자 증가 애니메이션 9종 — 한 줄 복붙으로CSS 숫자 증가 애니메이션은 0이나 시작값에서 목표 숫자까지 오르는 텍스트를 CSS 속성 하나로 세는 방식입니다. 아홉 개 중 하나는 거꾸로 세고, 또 하나는 스크롤해서 보이기 전엔 0에서 멈춰 있습니다. 숫자 아 이 글의 데모 전부 보기


