02밑줄 확장 포커스
테두리 없는 입력창 아래 밑줄이 가운데서부터 scaleX 로 좌우로 자라나 포커스된 칸을 알려줍니다.
쓰임미니멀한 설정 폼, 웹사이트·SNS 주소 입력창
:focus-withinscaleX300ms

<main class="stage">
<div class="ug is-demo">
<span class="ug__label">웹사이트</span>
<input class="ug__input" type="url" placeholder="https://example.com" autocomplete="url">
<span class="ug__underline" aria-hidden="true"></span>
<span class="ug__bloom" aria-hidden="true"></span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-base; // 밑줄이 자라는 시간
$easing: cubic-bezier(.2, 1.5, .35, 1); // 스프링 오버슛 — scaleX 가 1 을 지나 1.08 까지 뻗었다가 돌아온다
$color: $subject-ink; // 밑줄 색
@include stage($stage-yellow);
.ug {
position: relative;
width: min(240px, 82vw);
padding-bottom: $sp-3;
}
.ug__label {
display: block;
margin-bottom: $sp-2;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: rgba($stage-ink, .7);
}
.ug__input {
box-sizing: border-box;
width: 100%;
border: 0;
border-bottom: 2px solid rgba($stage-ink, .3);
padding: $sp-2 $sp-1;
font-weight: 500;
font-size: clamp(14px, 4vw, 16px);
line-height: 1;
font-family: inherit;
color: $stage-ink;
background: transparent;
&:focus { outline: none; }
}
.ug__underline {
position: absolute;
left: 0; right: 0; bottom: 0;
height: 2px;
background: $color;
transform: scaleX(0);
transform-origin: center;
transition: transform $duration $easing;
}
// 실사용: 입력이나 그 자식 어떤 곳에 포커스가 가도(:focus-within) 밑줄이 자란다
.ug:focus-within .ug__underline { transform: scaleX(1); }
// 포커스 순간 밑줄 중심에서 아래로 번지는 radial 글로우 확산 한 겹
.ug__bloom {
position: absolute;
left: 0; right: 0; bottom: -10px;
height: 30px;
background: radial-gradient(ellipse 60% 100% at 50% 0%, rgba($color, .25) 0%, rgba($color, 0) 72%);
opacity: 0;
pointer-events: none;
}
.ug:focus-within .ug__bloom { animation: ug-bloom $dur-base $ease-out; }
@keyframes ug-bloom {
0% { opacity: 0; transform: scaleX(.4); }
40% { opacity: 1; transform: scaleX(1); }
100% { opacity: 0; transform: scaleX(1.15); }
}
@media (prefers-reduced-motion: reduce) {
.ug__underline { transition: none; }
.ug:focus-within .ug__bloom { animation: 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);
}
.ug {
position: relative;
width: min(240px, 82vw);
padding-bottom: 12px;
}
.ug__label {
display: block;
margin-bottom: 8px;
font-weight: 700;
font-size: 13px;
line-height: 1;
font-family: inherit;
color: rgba(23, 20, 26, 0.7);
}
.ug__input {
box-sizing: border-box;
width: 100%;
border: 0;
border-bottom: 2px solid rgba(23, 20, 26, 0.3);
padding: 8px 4px;
font-weight: 500;
font-size: clamp(14px, 4vw, 16px);
line-height: 1;
font-family: inherit;
color: #17141a;
background: transparent;
}
.ug__input:focus {
outline: none;
}
.ug__underline {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 2px;
background: #17141a;
transform: scaleX(0);
transform-origin: center;
transition: transform 300ms cubic-bezier(0.2, 1.5, 0.35, 1);
}
.ug:focus-within .ug__underline {
transform: scaleX(1);
}
.ug__bloom {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
height: 30px;
background: radial-gradient(ellipse 60% 100% at 50% 0%, rgba(23, 20, 26, 0.25) 0%, rgba(23, 20, 26, 0) 72%);
opacity: 0;
pointer-events: none;
}
.ug:focus-within .ug__bloom {
animation: ug-bloom 300ms ease-out;
}
@keyframes ug-bloom {
0% {
opacity: 0;
transform: scaleX(0.4);
}
40% {
opacity: 1;
transform: scaleX(1);
}
100% {
opacity: 0;
transform: scaleX(1.15);
}
}
@media (prefers-reduced-motion: reduce) {
.ug__underline {
transition: none;
}
.ug:focus-within .ug__bloom {
animation: none;
}
}// .is-demo 자동 재생: 진짜 focus 를 오가며 :focus-within 을 그대로 탄다 (3줄)
var el = document.querySelector('.is-demo .ug__input');
var t = function () { document.activeElement === el ? el.blur() : el.focus({ preventScroll: true }); }; // preventScroll — iframe 안 포커스가 홈 그리드의 부모 스크롤을 끌어당기지 않게 (사용자 2026-09-10 실측)
t(); setInterval(t, 450);import { useState } from "react";
import type { CSSProperties, ChangeEvent } from "react";
import styles from "./UnderlineGrow.module.scss";
export type UnderlineGrowProps = {
label?: string;
placeholder?: string;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function UnderlineGrow({
label = "Website",
placeholder = "https://example.com",
duration = 300,
easing = "cubic-bezier(.2,1.5,.35,1)",
color = "#17141a",
}: UnderlineGrowProps) {
const [value, setValue] = useState("");
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.ug} style={vars}>
<span className={styles.label}>{label}</span>
<input
className={styles.input}
type="url"
placeholder={placeholder}
value={value}
onChange={(e: ChangeEvent<HTMLInputElement>) => setValue(e.target.value)}
/>
<span className={styles.underline} aria-hidden="true" />
<span className={styles.bloom} aria-hidden="true" />
</div>
);
}02 밑줄 확장 포커스 — 측정 누적면적 1.592% · 움직인 프레임 7/23GODRICH 원작 · zip 에 SCSS·React 포함 · CSS 입력창 검색창 포커스 애니메이션 9종 — 한 줄 복붙으로
이 데모가 속한 글
CSS 입력창 검색창 포커스 애니메이션 9종 — 한 줄 복붙으로CSS 입력창 애니메이션은 클릭하기 전·클릭한 순간·값을 다 채운 뒤까지 브라우저가 이미 쥐고 있는 :focus :focus-within :placeholder-shown :valid :invalid 상태를 그대로 이 글의 데모 전부 보기


