입력창 디자인 9가지 — 복붙하면 되는 폼 위젯
입력창 디자인은 전화번호, 카드 번호, 수량, 태그처럼 회원가입·결제 폼에서 자주 보이지만 순수 HTML만으로는 제대로 동작하지 않는 입력 위젯을 말합니다.
01 phone-format
02 card-number
03 currency-input
04 quantity-stepper
05 tag-input
06 textarea-autogrow
07 file-dropzone
08 otp-resend
09 inline-validation
자동 재생 · 눌러서 해당 항목으로 · 전부 한 zip
- 01 전화번호 자동 하이픈
- 02 카드 번호 4자리 자동 포맷
- 03 금액 콤마 자동 입력
- 04 수량 +/- 스테퍼
- 05 태그 입력창
- 06 자동 늘어나는 textarea
- 07 파일 드래그 앤 드롭 업로드
- 08 인증번호 재전송 타이머 버튼
- 09 실시간 인풋 검증 표시
아홉 개는 인기 순이 아니라 폼을 실제로 채우는 순서로 놓았습니다. 연락처와 결제 정보를 입력하고(01~03), 수량과 관심 태그를 고르고(04~05), 메모를 적고 파일을 첨부하고(06~07), 마지막으로 본인인증과 제출 전 폼 유효성 검사를 거치는(08~09) 흐름입니다. 이 흐름에서 숫자 여섯 칸만 남기면 인증번호 입력 UI의 9가지 상황이 되고, 같은 칸들이 가입 화면에 모여 있으면 회원가입 폼 입력창 9가지입니다.
| 번호 | 이름 | 언제 쓰나 |
|---|---|---|
| 01 | 전화번호 자동 하이픈 | 회원가입·배송지 연락처 |
| 02 | 카드 번호 4자리 자동 포맷 | 결제 폼 카드 번호 |
| 03 | 금액 콤마 자동 입력 | 후원·견적 금액 |
| 04 | 수량 +/- 스테퍼 | 장바구니·예약 인원 |
| 05 | 태그 입력창 | 키워드·수신자 다중 등록 |
| 06 | 자동 늘어나는 textarea | 후기·문의 내용 |
| 07 | 파일 드래그 앤 드롭 업로드 | 프로필 사진·첨부파일 |
| 08 | 인증번호 재전송 타이머 버튼 | 휴대폰·이메일 재인증 |
| 09 | 실시간 인풋 검증 표시 | 이메일·비밀번호 검증 |
01전화번호 자동 하이픈
css 입력창 디자인에서 무엇이 달라지나
숫자만 입력해도 010-1234-5678처럼 하이픈이 자동으로 들어갑니다.

<main class="stage">
<div class="field is-demo" id="field">
<label class="field__label" for="phone-input">전화번호</label>
<input class="field__input" id="phone-input" type="tel" inputmode="numeric" autocomplete="tel-national" placeholder="010-0000-0000" aria-describedby="phone-hint" maxlength="13">
<p class="field__hint" id="phone-hint">숫자만 입력해도 하이픈이 자동으로 들어갑니다</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-quick; // 포커스 링 전환 시간
$easing: $ease-out; // 포커스 링 전환 이징
$color: $subject-blue; // 포커스 링 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-ink);
.field {
box-sizing: border-box;
width: min(260px, 84vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-5 $sp-5 $sp-4;
box-shadow: $shadow-raised;
&__label {
display: block;
margin: 0 0 $sp-2;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__input {
box-sizing: border-box;
width: 100%;
border: 2px solid transparent;
border-radius: $r-control;
padding: $sp-3 $sp-4;
font-weight: 600;
font-size: clamp(15px, 4.4vw, 18px);
letter-spacing: .02em;
font-family: inherit;
color: $stage-ink;
background: #fff;
transition: border-color $duration $easing, box-shadow $duration $easing;
&:focus {
outline: none;
border-color: $color;
box-shadow: 0 0 0 3px rgba(47, 109, 246, .18);
}
}
&__hint {
margin: $sp-2 0 0;
font-size: 12px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, .6);
}
}
// ── 접근성: 모션 축소 시 포커스 링 전환을 즉시 처리 ────────────
@media (prefers-reduced-motion: reduce) {
.field__input { transition: 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);
}
.field {
box-sizing: border-box;
width: min(260px, 84vw);
background: #fff7e6;
border-radius: 16px;
padding: 20px 20px 16px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.field__label {
display: block;
margin: 0 0 8px;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.field__input {
box-sizing: border-box;
width: 100%;
border: 2px solid transparent;
border-radius: 12px;
padding: 12px 16px;
font-weight: 600;
font-size: clamp(15px, 4.4vw, 18px);
letter-spacing: 0.02em;
font-family: inherit;
color: #17141a;
background: #fff;
transition: border-color 220ms ease-out, box-shadow 220ms ease-out;
}
.field__input:focus {
outline: none;
border-color: #2f6df6;
box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.18);
}
.field__hint {
margin: 8px 0 0;
font-size: 12px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, 0.6);
}
@media (prefers-reduced-motion: reduce) {
.field__input {
transition: none;
}
}(function () {
var field = document.getElementById('field');
var input = document.getElementById('phone-input');
function format(digits) {
digits = digits.replace(/\D/g, '').slice(0, 11);
if (digits.length < 4) return digits;
if (digits.length < 8) return digits.slice(0, 3) + '-' + digits.slice(3);
return digits.slice(0, 3) + '-' + digits.slice(3, 7) + '-' + digits.slice(7);
}
input.addEventListener('input', function () {
input.value = format(input.value);
});
function stopDemo() {
if (!field.classList.contains('is-demo')) return;
field.classList.remove('is-demo');
clearInterval(timer);
input.value = '';
}
input.addEventListener('pointerdown', stopDemo);
input.addEventListener('keydown', stopDemo);
var digits = '01012345678';
var i = 0;
var timer = setInterval(function () {
if (i > digits.length) { i = 0; input.value = ''; return; }
input.value = format(digits.slice(0, i));
i++;
}, 160);
})();import { useRef, useState } from "react";
import styles from "./PhoneFormat.module.scss";
export type PhoneFormatProps = {
label?: string;
hint?: string;
color?: string;
};
function format(raw: string): string {
const d = raw.replace(/\D/g, "").slice(0, 11);
if (d.length < 4) return d;
if (d.length < 8) return `${d.slice(0, 3)}-${d.slice(3)}`;
return `${d.slice(0, 3)}-${d.slice(3, 7)}-${d.slice(7)}`;
}
export default function PhoneFormat({
label = "전화번호",
hint = "숫자만 입력해도 하이픈이 자동으로 들어갑니다",
color = "#2f6df6",
}: PhoneFormatProps) {
const [value, setValue] = useState("");
const id = useRef("phone-input-" + Math.random().toString(36).slice(2)).current;
return (
<div className={styles.field} style={{ ["--color" as string]: color }}>
<label className={styles.label} htmlFor={id}>{label}</label>
<input
className={styles.input}
id={id}
type="tel"
inputMode="numeric"
autoComplete="tel-national"
placeholder="010-0000-0000"
maxLength={13}
value={value}
aria-describedby={id + "-hint"}
onChange={(e: any) => setValue(format(e.target.value))}
/>
<p className={styles.hint} id={id + "-hint"}>{hint}</p>
</div>
);
}01 · 전화번호 자동 하이픈 — 측정 누적면적 0.857% · 움직인 프레임 15/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코드에서 볼 곳
붙여넣기로 11자리를 한 번에 넣어도 같은 규칙으로 다시 포맷됩니다.
function format(raw) {
const d = raw.replace(/\D/g, "").slice(0, 11);
if (d.length < 4) return d;
if (d.length < 8) return d.slice(0, 3) + "-" + d.slice(3);
return d.slice(0, 3) + "-" + d.slice(3, 7) + "-" + d.slice(7);
}
input.addEventListener("input", () => {
input.value = format(input.value);
});
02카드 번호 4자리 자동 포맷
화면에서 일어나는 일
카드 번호를 입력하면 네 자리마다 공백이 자동으로 들어가 실제 카드처럼 읽힙니다.

<main class="stage">
<div class="field is-demo" id="field">
<div class="field__top">
<label class="field__label" for="card-input">카드 번호</label>
<span class="field__brand" id="brand" aria-hidden="true"></span>
</div>
<input class="field__input" id="card-input" type="text" inputmode="numeric" autocomplete="cc-number" placeholder="0000 0000 0000 0000" maxlength="19">
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-instant; // 브랜드 라벨이 나타나는 시간
$easing: $ease-out;
$color: $stage-ink; // 브랜드 라벨 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-yellow);
.field {
box-sizing: border-box;
width: min(280px, 86vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-5;
box-shadow: $shadow-raised;
&__top {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: $sp-2;
margin: 0 0 $sp-2;
}
&__label {
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__brand {
font-weight: 800;
font-size: 12px;
line-height: 1;
font-family: inherit;
letter-spacing: .04em;
color: $color;
opacity: 0;
transition: opacity $duration $easing;
&:not(:empty) { opacity: .72; } // 흐린 글자 알파 하한 .72 — 크림 면 위 6.9:1
}
&__input {
box-sizing: border-box;
width: 100%;
border: 2px solid transparent;
border-radius: $r-control;
padding: $sp-3 $sp-4;
font-weight: 600;
font-size: clamp(14px, 4.4vw, 17px);
letter-spacing: .04em;
font-family: inherit;
color: $stage-ink;
background: #fff;
transition: border-color $duration $easing;
&:focus {
outline: none;
border-color: $subject-blue;
}
}
}
@media (prefers-reduced-motion: reduce) {
.field__brand, .field__input { transition: none; }
}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);
}
.field {
box-sizing: border-box;
width: min(280px, 86vw);
background: #fff7e6;
border-radius: 16px;
padding: 20px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.field__top {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
margin: 0 0 8px;
}
.field__label {
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.field__brand {
font-weight: 800;
font-size: 12px;
line-height: 1;
font-family: inherit;
letter-spacing: 0.04em;
color: #17141a;
opacity: 0;
transition: opacity 140ms ease-out;
}
.field__brand:not(:empty) {
opacity: 0.72;
}
.field__input {
box-sizing: border-box;
width: 100%;
border: 2px solid transparent;
border-radius: 12px;
padding: 12px 16px;
font-weight: 600;
font-size: clamp(14px, 4.4vw, 17px);
letter-spacing: 0.04em;
font-family: inherit;
color: #17141a;
background: #fff;
transition: border-color 140ms ease-out;
}
.field__input:focus {
outline: none;
border-color: #2f6df6;
}
@media (prefers-reduced-motion: reduce) {
.field__brand, .field__input {
transition: none;
}
}(function () {
var field = document.getElementById('field');
var input = document.getElementById('card-input');
var brand = document.getElementById('brand');
function brandOf(d) {
if (d[0] === '4') return 'VISA';
if (/^5[1-5]/.test(d)) return 'Mastercard';
if (/^3[47]/.test(d)) return 'AMEX';
return '';
}
function format(v) {
var d = v.replace(/\D/g, '').slice(0, 16);
var groups = d.match(/.{1,4}/g) || [];
brand.textContent = brandOf(d);
return groups.join(' ');
}
input.addEventListener('input', function () {
input.value = format(input.value);
});
function stopDemo() {
if (!field.classList.contains('is-demo')) return;
field.classList.remove('is-demo');
clearInterval(timer);
input.value = ''; brand.textContent = '';
}
input.addEventListener('pointerdown', stopDemo);
input.addEventListener('keydown', stopDemo);
var digits = '4539148803436467';
var i = 0;
var timer = setInterval(function () {
if (i > digits.length) { i = 0; input.value = ''; brand.textContent = ''; return; }
input.value = format(digits.slice(0, i));
i++;
}, 110);
})();import { useRef, useState } from "react";
import styles from "./CardNumber.module.scss";
export type CardNumberProps = {
label?: string;
};
function brandOf(d: string): string {
if (d[0] === "4") return "VISA";
if (/^5[1-5]/.test(d)) return "Mastercard";
if (/^3[47]/.test(d)) return "AMEX";
return "";
}
function format(raw: string): { value: string; brand: string } {
const d = raw.replace(/\D/g, "").slice(0, 16);
const groups = d.match(/.{1,4}/g) || [];
return { value: groups.join(" "), brand: brandOf(d) };
}
export default function CardNumber({ label = "카드 번호" }: CardNumberProps) {
const [value, setValue] = useState("");
const [brand, setBrand] = useState("");
const id = useRef("card-input-" + Math.random().toString(36).slice(2)).current;
return (
<div className={styles.field}>
<div className={styles.top}>
<label className={styles.label} htmlFor={id}>{label}</label>
<span className={styles.brand}>{brand}</span>
</div>
<input
className={styles.input}
id={id}
type="text"
inputMode="numeric"
autoComplete="cc-number"
placeholder="0000 0000 0000 0000"
maxLength={19}
value={value}
onChange={(e: any) => {
const r = format(e.target.value);
setValue(r.value);
setBrand(r.brand);
}}
/>
</div>
);
}02 · 카드 번호 4자리 자동 포맷 — 측정 누적면적 1.293% · 움직인 프레임 22/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코드 읽는 법
앞자리로 VISA·Mastercard·AMEX 여부도 함께 표시합니다.
function format(raw) {
const d = raw.replace(/\D/g, "").slice(0, 16);
const groups = d.match(/.{1,4}/g) || [];
return groups.join(" ");
}
function brandOf(d) {
if (d[0] === "4") return "VISA";
if (/^5[1-5]/.test(d)) return "Mastercard";
return "";
}
03금액 콤마 자동 입력
어떤 움직임인가
원화 기호가 앞에 붙은 입력창에 숫자를 넣으면 천 단위마다 콤마가 자동으로 붙습니다.

<main class="stage">
<div class="field is-demo" id="field">
<label class="field__label" for="amount-input">후원 금액</label>
<div class="field__frame">
<span class="field__prefix" aria-hidden="true">₩</span>
<input class="field__input" id="amount-input" type="text" inputmode="numeric" placeholder="0" aria-describedby="amount-hint">
</div>
<p class="field__hint" id="amount-hint">숫자만 입력하면 천 단위 콤마가 자동으로 붙습니다</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-quick;
$easing: $ease-out;
$color: $subject-blue;
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-orange);
.field {
box-sizing: border-box;
width: min(260px, 84vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-5 $sp-5 $sp-4;
box-shadow: $shadow-raised;
&__label {
display: block;
margin: 0 0 $sp-2;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__frame {
display: flex;
align-items: center;
gap: $sp-2;
border: 2px solid transparent;
border-radius: $r-control;
padding: $sp-3 $sp-4;
background: #fff;
transition: border-color $duration $easing;
&:focus-within { border-color: $color; }
}
&__prefix {
font-weight: 700;
font-size: clamp(15px, 4.4vw, 18px);
font-family: inherit;
color: rgba(23, 20, 26, .72);
}
&__input {
box-sizing: border-box;
flex: 1 1 auto;
min-width: 0;
border: 0;
padding: 0;
text-align: right;
font-weight: 700;
font-size: clamp(15px, 4.4vw, 18px);
font-family: inherit;
color: $stage-ink;
background: transparent;
&:focus { outline: none; }
}
&__hint {
margin: $sp-2 0 0;
font-size: 12px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, .6);
}
}
@media (prefers-reduced-motion: reduce) {
.field__frame { transition: none; }
}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);
}
.field {
box-sizing: border-box;
width: min(260px, 84vw);
background: #fff7e6;
border-radius: 16px;
padding: 20px 20px 16px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.field__label {
display: block;
margin: 0 0 8px;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.field__frame {
display: flex;
align-items: center;
gap: 8px;
border: 2px solid transparent;
border-radius: 12px;
padding: 12px 16px;
background: #fff;
transition: border-color 220ms ease-out;
}
.field__frame:focus-within {
border-color: #2f6df6;
}
.field__prefix {
font-weight: 700;
font-size: clamp(15px, 4.4vw, 18px);
font-family: inherit;
color: rgba(23, 20, 26, 0.72);
}
.field__input {
box-sizing: border-box;
flex: 1 1 auto;
min-width: 0;
border: 0;
padding: 0;
text-align: right;
font-weight: 700;
font-size: clamp(15px, 4.4vw, 18px);
font-family: inherit;
color: #17141a;
background: transparent;
}
.field__input:focus {
outline: none;
}
.field__hint {
margin: 8px 0 0;
font-size: 12px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, 0.6);
}
@media (prefers-reduced-motion: reduce) {
.field__frame {
transition: none;
}
}(function () {
var field = document.getElementById('field');
var input = document.getElementById('amount-input');
function format(v) {
var d = v.replace(/\D/g, '').replace(/^0+(?=\d)/, '').slice(0, 12);
return d ? Number(d).toLocaleString('ko-KR') : '';
}
input.addEventListener('input', function () {
input.value = format(input.value);
});
function stopDemo() {
if (!field.classList.contains('is-demo')) return;
field.classList.remove('is-demo');
clearInterval(timer);
input.value = '';
}
input.addEventListener('pointerdown', stopDemo);
input.addEventListener('keydown', stopDemo);
var digits = '1500000';
var i = 0;
var timer = setInterval(function () {
if (i > digits.length) { i = 0; input.value = ''; return; }
input.value = format(digits.slice(0, i));
i++;
}, 190);
})();import { useRef, useState } from "react";
import styles from "./CurrencyInput.module.scss";
export type CurrencyInputProps = {
label?: string;
hint?: string;
symbol?: string;
};
function format(raw: string): string {
const d = raw.replace(/\D/g, "").replace(/^0+(?=\d)/, "").slice(0, 12);
return d ? Number(d).toLocaleString("ko-KR") : "";
}
export default function CurrencyInput({
label = "후원 금액",
hint = "숫자만 입력하면 천 단위 콤마가 자동으로 붙습니다",
symbol = "₩",
}: CurrencyInputProps) {
const [value, setValue] = useState("");
const id = useRef("amount-input-" + Math.random().toString(36).slice(2)).current;
return (
<div className={styles.field}>
<label className={styles.label} htmlFor={id}>{label}</label>
<div className={styles.frame}>
<span className={styles.prefix} aria-hidden="true">{symbol}</span>
<input
className={styles.input}
id={id}
type="text"
inputMode="numeric"
placeholder="0"
aria-describedby={id + "-hint"}
value={value}
onChange={(e: any) => setValue(format(e.target.value))}
/>
</div>
<p className={styles.hint} id={id + "-hint"}>{hint}</p>
</div>
);
}03 · 금액 콤마 자동 입력 — 측정 누적면적 0.557% · 움직인 프레임 12/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
어디를 바꾸면 되나
앞자리의 불필요한 0도 함께 지워집니다.
function format(raw) {
const d = raw.replace(/\D/g, "").replace(/^0+(?=\d)/, "").slice(0, 12);
return d ? Number(d).toLocaleString("ko-KR") : "";
}
input.addEventListener("input", () => {
input.value = format(input.value);
});
04수량 +/- 스테퍼
무엇이 보이나
버튼을 누를 때마다 가운데 숫자가 1씩 바뀌고, 최솟값(1)에서는 − 버튼이 자동으로 흐려지고 눌리지 않습니다.

<main class="stage">
<div class="stepper is-demo" id="stepper" role="group" aria-label="수량 선택">
<button class="stepper__btn" id="minus" type="button" aria-label="수량 줄이기">−</button>
<input class="stepper__value" id="value" type="text" inputmode="numeric" pattern="[0-9]*" value="1" aria-label="수량">
<button class="stepper__btn" id="plus" type="button" aria-label="수량 늘리기">+</button>
</div>
<span id="announce" class="sr-only" aria-live="polite"></span>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-instant; // 버튼 눌림 전환 시간
$easing: $ease-out;
$color: $stage-ink; // 값 글자 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-paper);
.sr-only {
position: absolute; width: 1px; height: 1px;
padding: 0; margin: -1px; overflow: hidden;
clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.stepper {
display: flex;
align-items: stretch;
gap: $sp-2;
background: $subject-cream;
border-radius: $r-pill;
padding: $sp-2;
box-shadow: $shadow-raised;
&__btn {
box-sizing: border-box;
width: 40px;
border: 0;
border-radius: 50%;
background: #fff;
color: $color;
font-size: 20px;
font-weight: 700;
line-height: 1;
font-family: inherit;
cursor: pointer;
transition: transform $duration $easing, opacity $duration $easing;
&:active:not(:disabled) { transform: scale(.9); }
&:disabled { opacity: .35; cursor: not-allowed; }
&:focus-visible { outline: 2px solid $subject-blue; outline-offset: 2px; }
}
&__value {
box-sizing: border-box;
width: 52px;
border: 0;
background: transparent;
text-align: center;
font-weight: 800;
font-size: clamp(16px, 4.6vw, 19px);
font-family: inherit;
color: $color;
&:focus { outline: none; }
}
}
@media (prefers-reduced-motion: reduce) {
.stepper__btn { transition: 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);
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.stepper {
display: flex;
align-items: stretch;
gap: 8px;
background: #fff7e6;
border-radius: 999px;
padding: 8px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.stepper__btn {
box-sizing: border-box;
width: 40px;
border: 0;
border-radius: 50%;
background: #fff;
color: #17141a;
font-size: 20px;
font-weight: 700;
line-height: 1;
font-family: inherit;
cursor: pointer;
transition: transform 140ms ease-out, opacity 140ms ease-out;
}
.stepper__btn:active:not(:disabled) {
transform: scale(0.9);
}
.stepper__btn:disabled {
opacity: 0.35;
cursor: not-allowed;
}
.stepper__btn:focus-visible {
outline: 2px solid #2f6df6;
outline-offset: 2px;
}
.stepper__value {
box-sizing: border-box;
width: 52px;
border: 0;
background: transparent;
text-align: center;
font-weight: 800;
font-size: clamp(16px, 4.6vw, 19px);
font-family: inherit;
color: #17141a;
}
.stepper__value:focus {
outline: none;
}
@media (prefers-reduced-motion: reduce) {
.stepper__btn {
transition: none;
}
}(function () {
var wrap = document.getElementById('stepper');
var minus = document.getElementById('minus');
var plus = document.getElementById('plus');
var value = document.getElementById('value');
var announce = document.getElementById('announce');
var MIN = 1, MAX = 99;
var n = 1;
function render() {
value.value = n;
minus.disabled = n <= MIN;
plus.disabled = n >= MAX;
announce.textContent = '수량 ' + n + '개';
}
function set(v) { n = Math.min(MAX, Math.max(MIN, v)); render(); }
minus.addEventListener('click', function () { stopDemo(); set(n - 1); });
plus.addEventListener('click', function () { stopDemo(); set(n + 1); });
value.addEventListener('change', function () { stopDemo(); set(parseInt(value.value, 10) || MIN); });
value.addEventListener('pointerdown', stopDemo);
function stopDemo() {
if (!wrap.classList.contains('is-demo')) return;
wrap.classList.remove('is-demo');
clearInterval(timer);
}
var dir = 1;
var timer = setInterval(function () {
if (n >= 6) dir = -1;
if (n <= 1) dir = 1;
set(n + dir);
}, 260);
render();
})();import { useState } from "react";
import styles from "./QuantityStepper.module.scss";
export type QuantityStepperProps = {
min?: number;
max?: number;
initial?: number;
onChange?: (n: number) => void;
};
export default function QuantityStepper({
min = 1,
max = 99,
initial = 1,
onChange,
}: QuantityStepperProps) {
const [n, setN] = useState(initial);
const set = (v: number) => {
const next = Math.min(max, Math.max(min, v));
setN(next);
onChange?.(next);
};
return (
<div className={styles.stepper} role="group" aria-label="수량 선택">
<button
type="button"
className={styles.btn}
aria-label="수량 줄이기"
disabled={n <= min}
onClick={() => set(n - 1)}
>
−
</button>
<input
className={styles.value}
type="text"
inputMode="numeric"
pattern="[0-9]*"
aria-label="수량"
value={n}
onChange={(e: any) => set(parseInt(e.target.value, 10) || min)}
/>
<button
type="button"
className={styles.btn}
aria-label="수량 늘리기"
disabled={n >= max}
onClick={() => set(n + 1)}
>
+
</button>
<span className={styles.srOnly} aria-live="polite">{`수량 ${n}개`}</span>
</div>
);
}04 · 수량 +/- 스테퍼 — 측정 누적면적 0.676% · 움직인 프레임 12/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코드에서 볼 곳
const MIN = 1, MAX = 99;
function set(v) {
n = Math.min(MAX, Math.max(MIN, v));
value.value = n;
minus.disabled = n <= MIN;
plus.disabled = n >= MAX;
}
minus.addEventListener("click", () => set(n - 1));
plus.addEventListener("click", () => set(n + 1));
05태그 입력창
화면에서 일어나는 일
글자를 쓰고 Enter를 누르면 알약 모양 태그로 바뀌고, 빈 입력창에서 백스페이스를 누르면 마지막 태그가 지워집니다.

<main class="stage">
<div class="tags is-demo" id="wrap">
<label class="tags__label" for="tag-input">키워드</label>
<ul class="tags__list" id="list" aria-label="추가된 태그"></ul>
<input class="tags__input" id="tag-input" type="text" placeholder="입력 후 Enter" aria-describedby="tag-hint">
<p class="tags__hint" id="tag-hint">Enter로 추가 · 백스페이스로 삭제</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-quick; // 태그가 나타나는 시간
$easing: $ease-pop; // 팝 이징
$color: $subject-blue; // 태그 배경 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-ink);
.tags {
box-sizing: border-box;
width: min(272px, 84vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-4;
box-shadow: $shadow-raised;
&__label {
display: block;
margin: 0 0 $sp-1;
font-weight: 700;
font-size: 12px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__list {
display: flex;
flex-wrap: wrap;
gap: $sp-1;
margin: 0 0 $sp-2;
padding: 0;
list-style: none;
min-height: 24px;
}
&__chip {
display: flex;
align-items: center;
gap: $sp-1;
background: $subject-blue-deep; // 크림 면 위 칩 — 흰 글자가 4.5 넘게 deep 면(6.37:1)
color: $stage-paper;
border-radius: $r-pill;
padding: $sp-1 $sp-2 $sp-1 $sp-3;
font-size: 13px;
font-weight: 600;
font-family: inherit;
}
&__remove {
border: 0;
background: rgba(23, 20, 26, .25);
color: $stage-paper;
width: 18px;
height: 18px;
border-radius: 50%;
line-height: 1;
font-size: 12px;
cursor: pointer;
transition: background $duration $easing;
&:hover, &:focus-visible { background: rgba(255, 255, 255, .45); }
}
&__input {
box-sizing: border-box;
width: 100%;
border: 2px solid transparent;
border-radius: $r-control;
padding: $sp-3 $sp-4;
font-weight: 500;
font-size: clamp(14px, 4.2vw, 16px);
font-family: inherit;
color: $stage-ink;
background: #fff;
transition: border-color $duration $easing;
&:focus { outline: none; border-color: $color; }
}
&__hint {
margin: $sp-1 0 0;
font-size: 11px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, .72);
}
}
.tags.is-demo .tags__chip { animation: pop $duration $easing both; }
@keyframes pop {
0% { transform: scale(.5); opacity: 0; }
70% { transform: scale(1.06); opacity: 1; }
100% { transform: scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.tags__chip { animation: none; }
.tags__input, .tags__remove { transition: 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);
}
.tags {
box-sizing: border-box;
width: min(272px, 84vw);
background: #fff7e6;
border-radius: 16px;
padding: 16px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.tags__label {
display: block;
margin: 0 0 4px;
font-weight: 700;
font-size: 12px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.tags__list {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin: 0 0 8px;
padding: 0;
list-style: none;
min-height: 24px;
}
.tags__chip {
display: flex;
align-items: center;
gap: 4px;
background: #0a4fe8;
color: #ffffff;
border-radius: 999px;
padding: 4px 8px 4px 12px;
font-size: 13px;
font-weight: 600;
font-family: inherit;
}
.tags__remove {
border: 0;
background: rgba(23, 20, 26, 0.25);
color: #ffffff;
width: 18px;
height: 18px;
border-radius: 50%;
line-height: 1;
font-size: 12px;
cursor: pointer;
transition: background 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.tags__remove:hover, .tags__remove:focus-visible {
background: rgba(255, 255, 255, 0.45);
}
.tags__input {
box-sizing: border-box;
width: 100%;
border: 2px solid transparent;
border-radius: 12px;
padding: 12px 16px;
font-weight: 500;
font-size: clamp(14px, 4.2vw, 16px);
font-family: inherit;
color: #17141a;
background: #fff;
transition: border-color 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.tags__input:focus {
outline: none;
border-color: #2f6df6;
}
.tags__hint {
margin: 4px 0 0;
font-size: 11px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, 0.72);
}
.tags.is-demo .tags__chip {
animation: pop 220ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes pop {
0% {
transform: scale(0.5);
opacity: 0;
}
70% {
transform: scale(1.06);
opacity: 1;
}
100% {
transform: scale(1);
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.tags__chip {
animation: none;
}
.tags__input, .tags__remove {
transition: none;
}
}(function () {
var wrap = document.getElementById('wrap');
var list = document.getElementById('list');
var input = document.getElementById('tag-input');
var tags = [];
function render() {
list.innerHTML = '';
tags.forEach(function (t, idx) {
var li = document.createElement('li');
li.className = 'tags__chip';
var span = document.createElement('span');
span.textContent = t;
var btn = document.createElement('button');
btn.type = 'button';
btn.className = 'tags__remove';
btn.setAttribute('aria-label', t + ' 태그 삭제');
btn.textContent = '×';
btn.addEventListener('click', function () { stopDemo(); tags.splice(idx, 1); render(); });
li.appendChild(span); li.appendChild(btn);
list.appendChild(li);
});
}
function add(t) { t = t.trim(); if (t) { tags.push(t); render(); } }
input.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ',') {
e.preventDefault(); stopDemo(); add(input.value); input.value = '';
} else if (e.key === 'Backspace' && !input.value && tags.length) {
stopDemo(); tags.pop(); render();
}
});
input.addEventListener('pointerdown', stopDemo);
function stopDemo() {
if (!wrap.classList.contains('is-demo')) return;
wrap.classList.remove('is-demo');
clearInterval(timer);
}
var script = ['디자인', '리액트', 'CSS', '반응형'];
var step = 0, chars = '', paused = false;
var timer = setInterval(function () {
if (paused) return;
var word = script[step];
if (chars.length < word.length) {
chars += word[chars.length];
input.value = chars;
} else {
add(chars); input.value = ''; chars = ''; step++;
if (step >= script.length) {
paused = true;
setTimeout(function () { tags = []; step = 0; paused = false; render(); }, 500);
}
}
}, 140);
})();import { useState } from "react";
import styles from "./TagInput.module.scss";
export type TagInputProps = {
label?: string;
initialTags?: string[];
};
export default function TagInput({ label = "키워드", initialTags = [] }: TagInputProps) {
const [tags, setTags] = useState<string[]>(initialTags);
const [draft, setDraft] = useState("");
const add = (t: string) => {
const v = t.trim();
if (v) setTags((prev) => [...prev, v]);
};
const onKeyDown = (e: { key: string; preventDefault: () => void }) => {
if (e.key === "Enter" || e.key === ",") {
e.preventDefault();
add(draft);
setDraft("");
} else if (e.key === "Backspace" && !draft && tags.length) {
setTags((prev) => prev.slice(0, -1));
}
};
return (
<div className={styles.tags}>
<label className={styles.label}>{label}</label>
<ul className={styles.list} aria-label="추가된 태그">
{tags.map((t, i) => (
<li key={t + i} className={styles.chip}>
<span>{t}</span>
<button
type="button"
className={styles.remove}
aria-label={`${t} 태그 삭제`}
onClick={() => setTags((prev) => prev.filter((_, idx) => idx !== i))}
>
×
</button>
</li>
))}
</ul>
<input
className={styles.input}
type="text"
placeholder="입력 후 Enter"
value={draft}
onChange={(e: any) => setDraft(e.target.value)}
onKeyDown={onKeyDown}
/>
</div>
);
}05 · 태그 입력창 — 측정 누적면적 21.44% · 움직인 프레임 19/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코드 읽는 법
input.addEventListener("keydown", (e) => {
if (e.key === "Enter" || e.key === ",") {
e.preventDefault();
if (input.value.trim()) tags.push(input.value.trim());
input.value = "";
render();
} else if (e.key === "Backspace" && !input.value && tags.length) {
tags.pop();
render();
}
});
06자동 늘어나는 textarea
어떤 움직임인가
줄이 늘어날 때마다 스크롤 대신 입력창 높이 자체가 늘어나고, 정해 둔 최대 높이(132px)를 넘으면 그때부터 스크롤이 생깁니다.

<main class="stage">
<div class="grow is-demo" id="wrap">
<label class="grow__label" for="review">후기 작성</label>
<textarea class="grow__area" id="review" rows="1" placeholder="이 상품을 써 본 느낌을 알려주세요"></textarea>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-quick; // 높이가 늘어나는 시간
$easing: $ease-out;
$color: $subject-blue; // 포커스 테두리 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-yellow);
.grow {
box-sizing: border-box;
width: min(280px, 86vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-5 $sp-5 $sp-4;
box-shadow: $shadow-raised;
&__label {
display: block;
margin: 0 0 $sp-2;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__area {
box-sizing: border-box;
display: block;
width: 100%;
min-height: 40px;
max-height: 132px;
resize: none;
overflow-y: auto;
border: 2px solid transparent;
border-radius: $r-control;
padding: $sp-3 $sp-4;
font-weight: 500;
font-size: clamp(13px, 3.8vw, 15px);
line-height: 1.4;
font-family: inherit;
color: $stage-ink;
background: #fff;
transition: height $duration $easing, border-color $duration $easing;
&:focus { outline: none; border-color: $color; }
}
}
@media (prefers-reduced-motion: reduce) {
.grow__area { transition: none; }
}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);
}
.grow {
box-sizing: border-box;
width: min(280px, 86vw);
background: #fff7e6;
border-radius: 16px;
padding: 20px 20px 16px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.grow__label {
display: block;
margin: 0 0 8px;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.grow__area {
box-sizing: border-box;
display: block;
width: 100%;
min-height: 40px;
max-height: 132px;
resize: none;
overflow-y: auto;
border: 2px solid transparent;
border-radius: 12px;
padding: 12px 16px;
font-weight: 500;
font-size: clamp(13px, 3.8vw, 15px);
line-height: 1.4;
font-family: inherit;
color: #17141a;
background: #fff;
transition: height 220ms ease-out, border-color 220ms ease-out;
}
.grow__area:focus {
outline: none;
border-color: #2f6df6;
}
@media (prefers-reduced-motion: reduce) {
.grow__area {
transition: none;
}
}(function () {
var wrap = document.getElementById('wrap');
var area = document.getElementById('review');
var MAX = 132;
function resize() {
area.style.height = 'auto';
area.style.height = Math.min(area.scrollHeight, MAX) + 'px';
}
area.addEventListener('input', resize);
function stopDemo() {
if (!wrap.classList.contains('is-demo')) return;
wrap.classList.remove('is-demo');
clearInterval(timer);
}
area.addEventListener('pointerdown', stopDemo);
area.addEventListener('keydown', stopDemo);
var full = '배송이 빠르고 포장도 꼼꼼했어요.\n색감이 사진이랑 거의 똑같습니다.\n다음에 또 주문할게요, 감사합니다!';
var i = 0;
var timer = setInterval(function () {
if (i > full.length) { i = 0; area.value = ''; resize(); return; }
area.value = full.slice(0, i);
resize();
i += 2;
}, 90);
})();import { useRef, useState } from "react";
import styles from "./TextareaAutogrow.module.scss";
export type TextareaAutogrowProps = {
label?: string;
placeholder?: string;
maxHeight?: number;
};
export default function TextareaAutogrow({
label = "후기 작성",
placeholder = "이 상품을 써 본 느낌을 알려주세요",
maxHeight = 132,
}: TextareaAutogrowProps) {
const [value, setValue] = useState("");
const ref = useRef<HTMLTextAreaElement | null>(null);
const resize = () => {
const el = ref.current;
if (!el) return;
el.style.height = "auto";
el.style.height = Math.min(el.scrollHeight, maxHeight) + "px";
};
return (
<div className={styles.grow}>
<label className={styles.label}>{label}</label>
<textarea
ref={ref}
className={styles.area}
rows={1}
placeholder={placeholder}
value={value}
style={{ maxHeight }}
onChange={(e: any) => {
setValue(e.target.value);
resize();
}}
/>
</div>
);
}06 · 자동 늘어나는 textarea — 측정 누적면적 36.821% · 움직인 프레임 23/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
어디를 바꾸면 되나
function resize() {
// 먼저 auto로 되돌려야 scrollHeight가 줄어든 만큼도 다시 잰다
area.style.height = "auto";
const next = Math.min(area.scrollHeight, 132);
area.style.height = next + "px";
}
area.addEventListener("input", resize);
07파일 드래그 앤 드롭 업로드
무엇이 보이나
파일을 끌어다 놓으면 영역 테두리가 굵어지고, 놓는 순간 파일 이름이 칩으로 바뀝니다.

<main class="stage">
<div class="drop is-demo" id="drop">
<label class="drop__zone" for="file-input" id="zone">
<span class="drop__icon" aria-hidden="true">⬆</span>
<span class="drop__text">여기로 파일을 끌어다 놓거나 클릭하세요</span>
<input class="drop__input" type="file" id="file-input">
</label>
<p class="drop__file" id="filename" aria-live="polite"></p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-quick; // 테두리·배경 전환 시간
$easing: $ease-out;
$color: $subject-blue; // 드래그 중 강조 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-orange);
.drop {
box-sizing: border-box;
width: min(280px, 86vw);
}
.drop__zone {
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
gap: $sp-2;
width: 100%;
border: 2px dashed rgba(255, 255, 255, .7);
border-radius: $r-card;
padding: $sp-8 $sp-4;
cursor: pointer;
background: rgba(255, 255, 255, .12);
transition: border-color $duration $easing, background $duration $easing, transform $duration $easing;
&.is-over {
border-color: $color;
background: rgba(255, 255, 255, .28);
transform: scale(1.02);
}
&:focus-within { outline: 2px solid $color; outline-offset: 3px; }
}
.drop__icon {
font-size: 22px;
line-height: 1;
color: $stage-ink;
}
.drop__text {
font-weight: 600;
font-size: 13px;
line-height: 1.4;
text-align: center;
font-family: inherit;
color: $stage-ink;
}
.drop__input {
position: absolute;
width: 1px; height: 1px;
padding: 0; margin: -1px; overflow: hidden;
clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.drop__file {
margin: $sp-2 0 0;
min-height: 16px;
font-weight: 600;
font-size: 12px;
font-family: inherit;
color: $stage-ink;
border-radius: $r-xs;
display: inline-block;
&:not(:empty) { background: $subject-cream; padding: $sp-1 $sp-2; }
}
@media (prefers-reduced-motion: reduce) {
.drop__zone { transition: none; }
}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);
}
.drop {
box-sizing: border-box;
width: min(280px, 86vw);
}
.drop__zone {
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
width: 100%;
border: 2px dashed rgba(255, 255, 255, 0.7);
border-radius: 16px;
padding: 32px 16px;
cursor: pointer;
background: rgba(255, 255, 255, 0.12);
transition: border-color 220ms ease-out, background 220ms ease-out, transform 220ms ease-out;
}
.drop__zone.is-over {
border-color: #2f6df6;
background: rgba(255, 255, 255, 0.28);
transform: scale(1.02);
}
.drop__zone:focus-within {
outline: 2px solid #2f6df6;
outline-offset: 3px;
}
.drop__icon {
font-size: 22px;
line-height: 1;
color: #17141a;
}
.drop__text {
font-weight: 600;
font-size: 13px;
line-height: 1.4;
text-align: center;
font-family: inherit;
color: #17141a;
}
.drop__input {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.drop__file {
margin: 8px 0 0;
min-height: 16px;
font-weight: 600;
font-size: 12px;
font-family: inherit;
color: #17141a;
border-radius: 4px;
display: inline-block;
}
.drop__file:not(:empty) {
background: #fff7e6;
padding: 4px 8px;
}
@media (prefers-reduced-motion: reduce) {
.drop__zone {
transition: none;
}
}(function () {
var wrap = document.getElementById('drop');
var zone = document.getElementById('zone');
var input = document.getElementById('file-input');
var filename = document.getElementById('filename');
['dragenter', 'dragover'].forEach(function (ev) {
zone.addEventListener(ev, function (e) { e.preventDefault(); stopDemo(); zone.classList.add('is-over'); });
});
['dragleave', 'dragend'].forEach(function (ev) {
zone.addEventListener(ev, function () { zone.classList.remove('is-over'); });
});
zone.addEventListener('drop', function (e) {
e.preventDefault(); stopDemo();
zone.classList.remove('is-over');
var f = e.dataTransfer && e.dataTransfer.files[0];
if (f) show(f.name);
});
input.addEventListener('change', function () {
stopDemo();
if (input.files[0]) show(input.files[0].name);
});
input.addEventListener('pointerdown', stopDemo);
function show(name) { filename.textContent = '선택됨: ' + name; }
function stopDemo() {
if (!wrap.classList.contains('is-demo')) return;
wrap.classList.remove('is-demo');
clearInterval(timer);
zone.classList.remove('is-over');
filename.textContent = '';
}
var phase = 0;
var timer = setInterval(function () {
phase = (phase + 1) % 6;
if (phase === 1) { zone.classList.add('is-over'); filename.textContent = ''; }
else if (phase === 3) { zone.classList.remove('is-over'); show('디자인시안.png'); }
else if (phase === 5) { filename.textContent = ''; }
}, 320);
})();import { useRef, useState } from "react";
import styles from "./FileDropzone.module.scss";
export type FileDropzoneProps = {
text?: string;
onFile?: (file: File) => void;
};
export default function FileDropzone({
text = "여기로 파일을 끌어다 놓거나 클릭하세요",
onFile,
}: FileDropzoneProps) {
const [over, setOver] = useState(false);
const [name, setName] = useState("");
const inputRef = useRef<HTMLInputElement | null>(null);
const handleFile = (f?: File) => {
if (!f) return;
setName(f.name);
onFile?.(f);
};
return (
<div className={styles.drop}>
<label
className={over ? `${styles.zone} ${styles.over}` : styles.zone}
onDragEnter={(e: any) => { e.preventDefault(); setOver(true); }}
onDragOver={(e: any) => { e.preventDefault(); setOver(true); }}
onDragLeave={() => setOver(false)}
onDrop={(e: any) => {
e.preventDefault();
setOver(false);
handleFile(e.dataTransfer?.files?.[0]);
}}
>
<span className={styles.icon} aria-hidden="true">⬆</span>
<span className={styles.text}>{text}</span>
<input
ref={inputRef}
className={styles.input}
type="file"
onChange={(e: any) => handleFile(e.target.files?.[0])}
/>
</label>
<p className={styles.file} aria-live="polite">{name ? `선택됨: ${name}` : ""}</p>
</div>
);
}07 · 파일 드래그 앤 드롭 업로드 — 측정 누적면적 26.096% · 움직인 프레임 10/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코드에서 볼 곳
클릭하면 일반 파일 선택창도 그대로 열립니다.
zone.addEventListener("dragover", (e) => {
e.preventDefault();
zone.classList.add("is-over");
});
zone.addEventListener("drop", (e) => {
e.preventDefault();
zone.classList.remove("is-over");
const file = e.dataTransfer.files[0];
if (file) filename.textContent = "선택됨: " + file.name;
});
08인증번호 재전송 타이머 버튼
화면에서 일어나는 일
재전송 버튼을 누르면 60초 동안 비활성화되며, 남은 초가 버튼 글자 위에 실시간으로 줄어듭니다.

<main class="stage">
<div class="otp is-demo" id="otp">
<label class="otp__label" for="otp-input">인증번호 6자리</label>
<div class="otp__row">
<input class="otp__input" id="otp-input" type="text" inputmode="numeric" maxlength="6" placeholder="000000" autocomplete="one-time-code">
<button class="otp__resend" id="resend" type="button">재전송</button>
</div>
<p class="otp__status" id="status" aria-live="polite"></p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-instant;
$easing: $ease-out;
$color: $subject-blue; // 버튼 활성 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-paper);
.otp {
box-sizing: border-box;
width: min(280px, 86vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-5;
box-shadow: $shadow-raised;
&__label {
display: block;
margin: 0 0 $sp-2;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__row {
display: flex;
gap: $sp-2;
}
&__input {
box-sizing: border-box;
flex: 1 1 auto;
min-width: 0;
border: 2px solid transparent;
border-radius: $r-control;
padding: $sp-3 $sp-3;
font-weight: 600;
font-size: clamp(14px, 4.2vw, 16px);
letter-spacing: .12em;
font-family: inherit;
color: $stage-ink;
background: #fff;
&:focus { outline: none; border-color: $color; }
}
&__resend {
box-sizing: border-box;
flex: 0 0 auto;
border: 0;
border-radius: $r-control;
padding: 0 $sp-3;
font-weight: 700;
font-size: 12px;
font-family: inherit;
color: $stage-paper;
background: $color;
cursor: pointer;
transition: background $duration $easing, opacity $duration $easing;
&:disabled { background: rgba(23, 20, 26, .3); color: $subject-ink; cursor: not-allowed; } // 반투명 먹 위 흰 글자 2.10:1 → 잉크 8.76:1
&:focus-visible { outline: 2px solid $stage-ink; outline-offset: 2px; }
}
&__status {
margin: $sp-2 0 0;
min-height: 14px;
font-size: 11px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, .6);
}
}
@media (prefers-reduced-motion: reduce) {
.otp__resend { transition: 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);
}
.otp {
box-sizing: border-box;
width: min(280px, 86vw);
background: #fff7e6;
border-radius: 16px;
padding: 20px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.otp__label {
display: block;
margin: 0 0 8px;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.otp__row {
display: flex;
gap: 8px;
}
.otp__input {
box-sizing: border-box;
flex: 1 1 auto;
min-width: 0;
border: 2px solid transparent;
border-radius: 12px;
padding: 12px 12px;
font-weight: 600;
font-size: clamp(14px, 4.2vw, 16px);
letter-spacing: 0.12em;
font-family: inherit;
color: #17141a;
background: #fff;
}
.otp__input:focus {
outline: none;
border-color: #2f6df6;
}
.otp__resend {
box-sizing: border-box;
flex: 0 0 auto;
border: 0;
border-radius: 12px;
padding: 0 12px;
font-weight: 700;
font-size: 12px;
font-family: inherit;
color: #ffffff;
background: #2f6df6;
cursor: pointer;
transition: background 140ms ease-out, opacity 140ms ease-out;
}
.otp__resend:disabled {
background: rgba(23, 20, 26, 0.3);
color: #17141a;
cursor: not-allowed;
}
.otp__resend:focus-visible {
outline: 2px solid #17141a;
outline-offset: 2px;
}
.otp__status {
margin: 8px 0 0;
min-height: 14px;
font-size: 11px;
line-height: 1.4;
font-family: inherit;
color: rgba(23, 20, 26, 0.6);
}
@media (prefers-reduced-motion: reduce) {
.otp__resend {
transition: none;
}
}(function () {
var wrap = document.getElementById('otp');
var input = document.getElementById('otp-input');
var btn = document.getElementById('resend');
var status = document.getElementById('status');
var tickTimer = null;
function cooldown(seconds, tickMs, onDone) {
clearInterval(tickTimer);
var left = seconds;
btn.disabled = true;
btn.textContent = left + '초 후 재전송';
status.textContent = '인증번호를 다시 보냈습니다';
tickTimer = setInterval(function () {
left--;
if (left <= 0) {
clearInterval(tickTimer);
btn.disabled = false;
btn.textContent = '재전송';
if (onDone) onDone();
} else {
btn.textContent = left + '초 후 재전송';
}
}, tickMs);
}
function demoLoop() {
if (!wrap.classList.contains('is-demo')) return;
cooldown(8, 190, function () { setTimeout(demoLoop, 260); });
}
btn.addEventListener('click', function () {
stopDemo();
cooldown(60, 1000);
});
input.addEventListener('pointerdown', stopDemo);
function stopDemo() {
if (!wrap.classList.contains('is-demo')) return;
wrap.classList.remove('is-demo');
clearInterval(tickTimer);
btn.disabled = false;
btn.textContent = '재전송';
status.textContent = '';
}
demoLoop();
})();import { useEffect, useRef, useState } from "react";
import styles from "./OtpResend.module.scss";
export type OtpResendProps = {
seconds?: number;
onResend?: () => void;
};
export default function OtpResend({ seconds = 60, onResend }: OtpResendProps) {
const [code, setCode] = useState("");
const [left, setLeft] = useState(0);
const [status, setStatus] = useState("");
const timer = useRef<ReturnType<typeof setInterval> | null>(null);
useEffect(() => {
return () => { if (timer.current) clearInterval(timer.current); };
}, []);
const resend = () => {
onResend?.();
setStatus("인증번호를 다시 보냈습니다");
setLeft(seconds);
if (timer.current) clearInterval(timer.current);
timer.current = setInterval(() => {
setLeft((prev) => {
if (prev <= 1) {
if (timer.current) clearInterval(timer.current);
return 0;
}
return prev - 1;
});
}, 1000);
};
return (
<div className={styles.otp}>
<label className={styles.label} htmlFor="otp-code">인증번호 6자리</label>
<div className={styles.row}>
<input
className={styles.input}
id="otp-code"
type="text"
inputMode="numeric"
maxLength={6}
placeholder="000000"
autoComplete="one-time-code"
value={code}
onChange={(e: any) => setCode(e.target.value.replace(/\D/g, ""))}
/>
<button
type="button"
className={styles.resend}
disabled={left > 0}
onClick={resend}
>
{left > 0 ? `${left}초 후 재전송` : "재전송"}
</button>
</div>
<p className={styles.status} aria-live="polite">{status}</p>
</div>
);
}08 · 인증번호 재전송 타이머 버튼 — 측정 누적면적 3.449% · 움직인 프레임 15/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
코드 읽는 법
0초가 되면 다시 눌립니다.
function cooldown(seconds) {
let left = seconds;
btn.disabled = true;
btn.textContent = left + "초 후 재전송";
const t = setInterval(() => {
left--;
if (left <= 0) {
clearInterval(t);
btn.disabled = false;
btn.textContent = "재전송";
} else {
btn.textContent = left + "초 후 재전송";
}
}, 1000);
}
09실시간 인풋 검증 표시
어떤 움직임인가
입력하는 동안 이메일 형식이 맞으면 초록 체크가, 틀리면 빨간 문구가 그 자리에서 바로 나타납니다.

<main class="stage">
<div class="valid is-demo" id="wrap">
<label class="valid__label" for="email-input">이메일</label>
<div class="valid__frame" id="frame">
<input class="valid__input" id="email-input" type="email" placeholder="[email protected]" aria-describedby="email-msg">
<span class="valid__icon" id="icon" aria-hidden="true"></span>
</div>
<p class="valid__msg" id="email-msg" role="status"></p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-quick;
$easing: $ease-pop;
$color: $error; // 오류 색 (성공은 토큰 blue 대신 아래 green 사용)
$ok: #4b976b;
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-ink);
.valid {
box-sizing: border-box;
width: min(270px, 86vw);
background: $subject-cream;
border-radius: $r-card;
padding: $sp-5 $sp-5 $sp-4;
box-shadow: $shadow-raised;
&__label {
display: block;
margin: 0 0 $sp-2;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: $stage-ink;
}
&__frame {
position: relative;
border: 2px solid transparent;
border-radius: $r-control;
background: #fff;
transition: border-color $duration $easing;
&.is-ok { border-color: $ok; }
&.is-bad { border-color: $color; }
}
&__input {
box-sizing: border-box;
width: 100%;
border: 0;
border-radius: inherit;
padding: $sp-3 $sp-8 $sp-3 $sp-4;
font-weight: 500;
font-size: clamp(13px, 3.8vw, 15px);
font-family: inherit;
color: $stage-ink;
background: transparent;
&:focus { outline: none; }
}
&__icon {
position: absolute;
right: $sp-3;
top: 50%;
transform: translateY(-50%) scale(0);
font-weight: 800;
font-size: 15px;
line-height: 1;
transition: transform $duration $easing;
}
&__frame.is-ok &__icon { color: $ok; transform: translateY(-50%) scale(1); }
&__frame.is-bad &__icon { color: $color; transform: translateY(-50%) scale(1); }
&__msg {
margin: $sp-2 0 0;
min-height: 14px;
font-size: 12px;
line-height: 1.4;
font-weight: 600;
font-family: inherit;
color: $color;
}
}
@media (prefers-reduced-motion: reduce) {
.valid__frame, .valid__icon { transition: 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);
}
.valid {
box-sizing: border-box;
width: min(270px, 86vw);
background: #fff7e6;
border-radius: 16px;
padding: 20px 20px 16px;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.valid__label {
display: block;
margin: 0 0 8px;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: #17141a;
}
.valid__frame {
position: relative;
border: 2px solid transparent;
border-radius: 12px;
background: #fff;
transition: border-color 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.valid__frame.is-ok {
border-color: #4b976b;
}
.valid__frame.is-bad {
border-color: #c2361a;
}
.valid__input {
box-sizing: border-box;
width: 100%;
border: 0;
border-radius: inherit;
padding: 12px 32px 12px 16px;
font-weight: 500;
font-size: clamp(13px, 3.8vw, 15px);
font-family: inherit;
color: #17141a;
background: transparent;
}
.valid__input:focus {
outline: none;
}
.valid__icon {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%) scale(0);
font-weight: 800;
font-size: 15px;
line-height: 1;
transition: transform 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.valid__frame.is-ok .valid__icon {
color: #4b976b;
transform: translateY(-50%) scale(1);
}
.valid__frame.is-bad .valid__icon {
color: #c2361a;
transform: translateY(-50%) scale(1);
}
.valid__msg {
margin: 8px 0 0;
min-height: 14px;
font-size: 12px;
line-height: 1.4;
font-weight: 600;
font-family: inherit;
color: #c2361a;
}
@media (prefers-reduced-motion: reduce) {
.valid__frame, .valid__icon {
transition: none;
}
}(function () {
var wrap = document.getElementById('wrap');
var frame = document.getElementById('frame');
var input = document.getElementById('email-input');
var icon = document.getElementById('icon');
var msg = document.getElementById('email-msg');
var RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
function check(v) {
frame.classList.remove('is-ok', 'is-bad');
if (!v) { icon.textContent = ''; msg.textContent = ''; return; }
if (RE.test(v)) {
frame.classList.add('is-ok'); icon.textContent = '✓'; msg.textContent = '';
} else {
frame.classList.add('is-bad'); icon.textContent = '!'; msg.textContent = '이메일 형식을 확인해 주세요';
}
}
input.addEventListener('input', function () { check(input.value); });
input.addEventListener('pointerdown', stopDemo);
input.addEventListener('keydown', stopDemo);
function stopDemo() {
if (!wrap.classList.contains('is-demo')) return;
wrap.classList.remove('is-demo');
clearInterval(timer);
input.value = ''; check('');
}
var script = ['g', 'go', 'god', 'godrich', 'godrich@', 'godrich@mail', '[email protected]'];
var i = 0;
var timer = setInterval(function () {
if (i >= script.length) { i = 0; input.value = ''; check(''); return; }
input.value = script[i]; check(script[i]); i++;
}, 260);
})();import { useState } from "react";
import styles from "./InlineValidation.module.scss";
export type InlineValidationProps = {
label?: string;
};
const RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
export default function InlineValidation({ label = "이메일" }: InlineValidationProps) {
const [value, setValue] = useState("");
const state = value === "" ? "idle" : RE.test(value) ? "ok" : "bad";
return (
<div className={styles.valid}>
<label className={styles.label} htmlFor="email-field">{label}</label>
<div className={`${styles.frame} ${state === "ok" ? styles.ok : ""} ${state === "bad" ? styles.badState : ""}`}>
<input
className={styles.input}
id="email-field"
type="email"
placeholder="[email protected]"
aria-describedby="email-field-msg"
value={value}
onChange={(e: any) => setValue(e.target.value)}
/>
<span className={styles.icon} aria-hidden="true">
{state === "ok" ? "✓" : state === "bad" ? "!" : ""}
</span>
</div>
<p className={styles.msg} id="email-field-msg" role="status">
{state === "bad" ? "이메일 형식을 확인해 주세요" : ""}
</p>
</div>
);
}09 · 실시간 인풋 검증 표시 — 측정 누적면적 3.935% · 움직인 프레임 14/23GODRICH 원작 · zip 에 SCSS·React 포함 · 비밀번호 보기
어디를 바꾸면 되나
값이 비어 있으면 아무 표시도 하지 않습니다.
const RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
input.addEventListener("input", () => {
const v = input.value;
frame.classList.remove("is-ok", "is-bad");
if (!v) { icon.textContent = ""; msg.textContent = ""; return; }
if (RE.test(v)) { frame.classList.add("is-ok"); icon.textContent = "✓"; }
else { frame.classList.add("is-bad"); icon.textContent = "!"; msg.textContent = "이메일 형식을 확인해 주세요"; }
});
어디서 깨지는가 — 함정 하나
01·02·03의 자동 포맷 입력창은 전부 같은 함정을 안고 있습니다. input.value = format(value)처럼 값을 통째로 다시 쓰면, 브라우저는 커서(캐럿) 위치를 항상 문자열 맨 끝으로 되돌립니다. 가운데 자릿수를 고치려고 입력창 중간을 클릭해도, 다음 글자를 치는 순간 커서가 끝으로 튀어버립니다. 짧은 전화번호·카드 번호 입력에서는 크게 거슬리지 않지만, 길게 수정하는 입력창이라면 MDN의 HTMLInputElement.setSelectionRange 문서를 참고해 재포맷 전 커서 위치를 저장했다가 되돌려 주는 처리가 필요합니다. 입력 다음의 선택이 궁금해지면 달력 선택 UI 9종이 그 다음 단의 위젯을 이어받습니다. 이 함정을 포함해 아홉 개 파일 전부에 실제로 동작하는 바닐라 JS와 React 버전을 담은 압축 파일의 비밀번호는 puc8udvv이고, 아래 버튼으로 받을 수 있습니다.
07의 드래그 앤 드롭도 비슷하게 놓치기 쉬운 부분이 있습니다. dragover 이벤트에서 preventDefault()를 호출하지 않으면 브라우저가 기본 동작(파일을 새 탭으로 여는 것)을 실행해 버려 drop 이벤트 자체가 발생하지 않습니다. 위 코드 조각에도 이 처리가 들어 있는 이유입니다.
접근성
아홉 개 모두 라벨과 입력창을 label·for로 연결했고, 04의 수량 버튼은 화면에 보이지 않는 aria-live 영역으로 "수량 3개"처럼 변경값을 스크린 리더에 알립니다. 08의 재전송 버튼은 aria-live="polite"인 상태 문구로 재전송 완료를 알리고, 09의 검증 문구는 role="status"로 값이 바뀔 때만 조용히 갱신됩니다. 07의 파일 입력은 화면에서는 숨겨져 있지만 Tab으로 포커스가 가고 Enter·Space로 파일 선택창이 열려, 마우스 없이도 끝까지 쓸 수 있습니다. 색·테두리 전환에는 전부 MDN의 prefers-reduced-motion 문서에 따라 모션을 줄이는 사용자를 위한 처리를 넣었습니다.
@media (prefers-reduced-motion: reduce) {
.field__input, .drop__zone, .valid__frame { transition: none; }
}
다른 폼·인풋 관련 편은 인증번호 입력 UI 9종에서 이어 볼 수 있고, 이 사이트가 무엇을 다루는지는 소개에 정리돼 있습니다.
FAQ
이 아홉 개를 리액트 프로젝트에도 그대로 쓸 수 있습니까?
네. 압축 파일 안 react/ 폴더에 항목마다 .tsx와 .module.scss가 따로 들어 있어, vanilla/의 순수 JS 버전과 같은 동작을 훅으로 옮겨 뒀습니다. props로 색·라벨 문구 정도만 바꿔 쓰면 됩니다.
카드 번호 자동 포맷이 결제 보안에도 영향을 줍니까?
아닙니다. 여기서 다루는 건 화면에 숫자를 보기 좋게 4자리씩 나눠 보여주는 표시 방식일 뿐이고, 카드 정보를 실제로 처리·저장하는 건 결제대행사(PG)의 몫입니다. 자동 포맷 자체는 카드 데이터를 서버로 보내지 않습니다. 제출 직전에 입력값을 실시간으로 판정하는 화면은 폼 유효성 검사 UI 9종이 맡습니다.
입력 폼 디자인에서 전화번호·카드 번호 칸에 모바일 숫자 키패드가 자동으로 뜨나요?
네, inputmode="numeric"을 넣어 뒀기 때문에 대부분의 모바일 브라우저가 문자 키패드 대신 숫자 키패드를 먼저 보여줍니다. 다만 이는 힌트일 뿐이라 브라우저마다 미세하게 다르게 동작할 수 있습니다.









