01リアルタイムのインラインエラー
メール欄の下にあらかじめ確保した行が、opacityとtranslateYだけでわずかに滑り込み、また消えます。
使いどころ会員登録フォームのメール欄、ログインフォームのリアルタイム検証
opacitytranslateY2s 루프

<main class="stage">
<div class="fv1 is-demo">
<label class="fv1__label" for="fv1-email">メール</label>
<input class="fv1__input" id="fv1-email" type="email" value="wrong@mail" readonly aria-invalid="true">
<p class="fv1__msg" role="alert">正しいメール形式ではありません</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// 실시간 인라인 에러 메시지: opacity + translateY 만 쓴다
$duration: $dur-loop;
$easing: $ease-out;
$color: $error;
@include stage($stage-ink);
.fv1 { width: min(260px, 86vw); display: flex; flex-direction: column; gap: $sp-2; }
.fv1__label { font-weight: 600; font-size: 12px; line-height: 1; font-family: inherit; color: $subject-cream; }
.fv1__input {
box-sizing: border-box; width: 100%;
padding: $sp-2 $sp-3; border-radius: $r-sm;
border: 2px solid $color; background: rgba(255, 255, 255, .06);
color: $subject-cream; font-weight: 400; font-size: 14px; line-height: 1; font-family: inherit;
}
.fv1__msg {
margin: 0; color: $color; font-weight: 500; font-size: 11px; line-height: 1.3; font-family: inherit;
opacity: 0; transform: translateY(-6px);
}
@keyframes fv1-in {
0%, 6% { opacity: 0; transform: translateY(-6px); }
28%, 78% { opacity: 1; transform: translateY(0); }
100% { opacity: 0; transform: translateY(-6px); }
}
.fv1.is-demo .fv1__msg { animation: fv1-in $duration $easing infinite; }
// 한 겹(감쇠 진동): 메시지 등장(28%) 순간 필드에 미세 translateX 감쇠 shake + 테두리 글로우가 box-shadow spread 로 한 번 번지는 surge 파동
// (input 요소엔 ::after 가 렌더되지 않으므로 링은 box-shadow spread 로 구현 — border-color 불변)
.fv1.is-demo .fv1__input {
animation: fv1-shake $duration $easing infinite, fv1-surge $duration $easing infinite;
}
@keyframes fv1-shake {
0%, 28%, 34%, 100% { transform: translateX(0); }
29.5% { transform: translateX(.6px); }
31% { transform: translateX(-.4px); }
32.5% { transform: translateX(.2px); }
}
@keyframes fv1-surge {
0%, 28% { box-shadow: 0 0 0 0 rgba($color, 0); }
30% { box-shadow: 0 0 0 6px rgba($color, .45); }
32% { box-shadow: 0 0 0 2px rgba($color, .2); }
34% { box-shadow: 0 0 0 3.5px rgba($color, .28); }
38%, 100% { box-shadow: 0 0 0 0 rgba($color, 0); }
}
@media (prefers-reduced-motion: reduce) {
.fv1.is-demo .fv1__msg { animation: none !important; opacity: 1; transform: translateY(0); }
.fv1.is-demo .fv1__input { animation: none !important; }
}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);
}
.fv1 {
width: min(260px, 86vw);
display: flex;
flex-direction: column;
gap: 8px;
}
.fv1__label {
font-weight: 600;
font-size: 12px;
line-height: 1;
font-family: inherit;
color: #fff7e6;
}
.fv1__input {
box-sizing: border-box;
width: 100%;
padding: 8px 12px;
border-radius: 8px;
border: 2px solid #c2361a;
background: rgba(255, 255, 255, 0.06);
color: #fff7e6;
font-weight: 400;
font-size: 14px;
line-height: 1;
font-family: inherit;
}
.fv1__msg {
margin: 0;
color: #c2361a;
font-weight: 500;
font-size: 11px;
line-height: 1.3;
font-family: inherit;
opacity: 0;
transform: translateY(-6px);
}
@keyframes fv1-in {
0%, 6% {
opacity: 0;
transform: translateY(-6px);
}
28%, 78% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(-6px);
}
}
.fv1.is-demo .fv1__msg {
animation: fv1-in 2s ease-out infinite;
}
.fv1.is-demo .fv1__input {
animation: fv1-shake 2s ease-out infinite, fv1-surge 2s ease-out infinite;
}
@keyframes fv1-shake {
0%, 28%, 34%, 100% {
transform: translateX(0);
}
29.5% {
transform: translateX(0.6px);
}
31% {
transform: translateX(-0.4px);
}
32.5% {
transform: translateX(0.2px);
}
}
@keyframes fv1-surge {
0%, 28% {
box-shadow: 0 0 0 0 rgba(194, 54, 26, 0);
}
30% {
box-shadow: 0 0 0 6px rgba(194, 54, 26, 0.45);
}
32% {
box-shadow: 0 0 0 2px rgba(194, 54, 26, 0.2);
}
34% {
box-shadow: 0 0 0 3.5px rgba(194, 54, 26, 0.28);
}
38%, 100% {
box-shadow: 0 0 0 0 rgba(194, 54, 26, 0);
}
}
@media (prefers-reduced-motion: reduce) {
.fv1.is-demo .fv1__msg {
animation: none !important;
opacity: 1;
transform: translateY(0);
}
.fv1.is-demo .fv1__input {
animation: none !important;
}
}import type { CSSProperties } from "react";
import styles from "./RealtimeInlineMessage.module.scss";
export type RealtimeInlineMessageProps = { duration?: number; easing?: string; color?: string };
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function RealtimeInlineMessage({ duration = 2000, easing = "ease-out", color = "#c2361a" }: RealtimeInlineMessageProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.fv1} style={vars}>
<label className={styles.label} htmlFor="fv1-email">이메일</label>
<input id="fv1-email" className={styles.input} type="email" defaultValue="wrong@mail" readOnly aria-invalid="true" />
<p className={styles.msg} role="alert">올바른 이메일 형식이 아니에요</p>
</div>
);
}01 リアルタイムのインラインエラー — 計測 累積面積 3.469% · 動いたフレーム 13/23GODRICH オリジナル · SCSS と React は zip に同梱 · CSS バリデーション アニメーション9選 — フォーム入力エラーの見せ方
このデモが属する記事
CSS バリデーション アニメーション9選 — フォーム入力エラーの見せ方CSS バリデーションのアニメーションは、揺れではなく色・アイコン・グローのような別の合図で、フォームの値が合っているか間違っているかを伝える動きです。以下9つはコピペで動く形にまとめ、会員登録フォームで実際に起きる順番に並べました。 この記事のデモをすべて見る


