07縦タブ
タブが縦に積まれたサイドメニューで、選んだタブの左にあるバー型インジケーターがtranslateYで上下に滑り、いま開いている項目を示す。
使いどころ設定画面のアカウント・通知・セキュリティのサイドタブ、ドキュメントサイトの目次
translateY:checked300ms

<main class="stage">
<div class="vt is-demo">
<input type="radio" name="vt-tab" id="vt-1" class="vt__radio" checked>
<input type="radio" name="vt-tab" id="vt-2" class="vt__radio">
<input type="radio" name="vt-tab" id="vt-3" class="vt__radio">
<div class="vt__nav">
<span class="vt__trail" aria-hidden="true"></span>
<span class="vt__indicator" aria-hidden="true"></span>
<label class="vt__tab" for="vt-1">アカウント</label>
<label class="vt__tab" for="vt-2">通知</label>
<label class="vt__tab" for="vt-3">セキュリティ</label>
</div>
<div class="vt__panels">
<p class="vt__panel vt__panel--1">名前とメールアドレスを変更します。</p>
<p class="vt__panel vt__panel--2">プッシュ・メール通知を選びます。</p>
<p class="vt__panel vt__panel--3">パスワードと2段階認証を管理します。</p>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-base; // 인디케이터가 위아래로 미끄러지는 시간
$easing: $ease-lerp-settle; // 관성 lerp — 목표를 12.6% 넘겼다가 정착 (2026-09-15 형태 2차 한 겹)
$color: $subject-cream; // 인디케이터 색
@include stage($stage-orange);
$row-h: 36px;
.vt { display: flex; gap: $sp-6; width: min(280px, 82vw); }
.vt__radio { position: absolute; opacity: 0; pointer-events: none; }
.vt__nav {
position: relative;
display: flex;
flex-direction: column;
flex: 0 0 auto;
border-left: 2px solid rgba(255, 247, 230, .18);
padding-left: $sp-4;
}
.vt__tab {
height: $row-h;
display: flex;
align-items: center;
font-weight: 600;
font-size: clamp(12px, 3.4vw, 14px);
line-height: 1;
font-family: inherit;
color: rgba($subject-ink, .85); // 비활성 탭 — 주황 면 위 4.62:1
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.vt__indicator {
position: absolute; left: -2px; top: 0;
width: 2px; height: $row-h;
background: $color;
border-radius: $r-xs;
transform: translateY(0);
transition: transform $duration $easing;
}
// 이동 궤적 트레일 잔상 — 인디케이터보다 1.8배 느리게 같은 목적지를 쫓아가며 뒤로 흐른다
.vt__trail {
position: absolute; left: -2px; top: 0;
width: 2px; height: $row-h;
background: $color;
border-radius: $r-xs;
opacity: .32;
filter: blur(1.5px);
transform: translateY(0);
transition: transform calc($duration * 1.8) ease-out;
}
// ── 실제 동작: :checked 만으로 인디케이터가 세로로 옮겨간다 ──────────────
#vt-1:checked ~ .vt__nav .vt__indicator { transform: translateY(0); }
#vt-2:checked ~ .vt__nav .vt__indicator { transform: translateY(#{$row-h}); }
#vt-3:checked ~ .vt__nav .vt__indicator { transform: translateY(#{$row-h * 2}); }
#vt-1:checked ~ .vt__nav .vt__trail { transform: translateY(0); }
#vt-2:checked ~ .vt__nav .vt__trail { transform: translateY(#{$row-h}); }
#vt-3:checked ~ .vt__nav .vt__trail { transform: translateY(#{$row-h * 2}); }
#vt-1:checked ~ .vt__nav label[for="vt-1"],
#vt-2:checked ~ .vt__nav label[for="vt-2"],
#vt-3:checked ~ .vt__nav label[for="vt-3"] { color: $subject-ink; } // 활성 탭 글자 — 크림은 3.11 로 미달 ($color 인디케이터는 그대로)
// 패널 세 개를 같은 grid 칸에 포개 두면 인디케이터와 함께 바뀌어도 자리가 안 흔들린다
.vt__panels { position: relative; display: grid; flex: 1 1 auto; min-width: 0; }
.vt__panel {
grid-area: 1 / 1;
margin: 0;
color: $subject-ink; // 패널 본문 — 5.50:1
font-weight: 400;
font-size: clamp(12px, 3.2vw, 13px);
line-height: 1.5;
font-family: inherit;
opacity: 0;
transition: opacity $duration $easing;
}
#vt-1:checked ~ .vt__panels .vt__panel--1,
#vt-2:checked ~ .vt__panels .vt__panel--2,
#vt-3:checked ~ .vt__panels .vt__panel--3 { opacity: 1; }
// ── 데모 루프: 클릭 전까지 세 탭을 스스로 오간다 (인디케이터·패널이 같은 박자) ──────────────
.vt.is-demo .vt__indicator { animation: vt-loop $dur-loop $easing infinite; }
.vt.is-demo .vt__trail { animation: vt-loop $dur-loop $easing infinite; animation-delay: calc($dur-loop * .06); } // 6% 위상만큼 늦게 쫓아가 트레일로 읽힌다
.vt.is-demo .vt__panel--1 { animation: vt-panel-1 $dur-loop $easing infinite; }
.vt.is-demo .vt__panel--2 { animation: vt-panel-2 $dur-loop $easing infinite; }
.vt.is-demo .vt__panel--3 { animation: vt-panel-3 $dur-loop $easing infinite; }
@keyframes vt-loop {
0%, 15% { transform: translateY(0); }
33%, 48% { transform: translateY(#{$row-h}); }
66%, 81% { transform: translateY(#{$row-h * 2}); }
100% { transform: translateY(0); }
}
@keyframes vt-panel-1 { 0%, 15% { opacity: 1; } 30%, 100% { opacity: 0; } }
@keyframes vt-panel-2 { 0%, 30% { opacity: 0; } 45%, 63% { opacity: 1; } 78%, 100% { opacity: 0; } }
@keyframes vt-panel-3 { 0%, 63% { opacity: 0; } 78%, 96% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
.vt__indicator, .vt__panel, .vt__trail { transition: none; }
.vt.is-demo .vt__indicator,
.vt.is-demo .vt__panel--1,
.vt.is-demo .vt__panel--2,
.vt.is-demo .vt__panel--3,
.vt.is-demo .vt__trail { animation: none !important; }
.vt__trail { opacity: 0; } // 관성·트레일 한 겹은 reduced-motion 에서 완전히 꺼진다
}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);
}
.vt {
display: flex;
gap: 24px;
width: min(280px, 82vw);
}
.vt__radio {
position: absolute;
opacity: 0;
pointer-events: none;
}
.vt__nav {
position: relative;
display: flex;
flex-direction: column;
flex: 0 0 auto;
border-left: 2px solid rgba(255, 247, 230, 0.18);
padding-left: 16px;
}
.vt__tab {
height: 36px;
display: flex;
align-items: center;
font-weight: 600;
font-size: clamp(12px, 3.4vw, 14px);
line-height: 1;
font-family: inherit;
color: rgba(23, 20, 26, 0.85);
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.vt__indicator {
position: absolute;
left: -2px;
top: 0;
width: 2px;
height: 36px;
background: #fff7e6;
border-radius: 4px;
transform: translateY(0);
transition: transform 300ms linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1);
}
.vt__trail {
position: absolute;
left: -2px;
top: 0;
width: 2px;
height: 36px;
background: #fff7e6;
border-radius: 4px;
opacity: 0.32;
filter: blur(1.5px);
transform: translateY(0);
transition: transform 540ms ease-out;
}
#vt-1:checked ~ .vt__nav .vt__indicator {
transform: translateY(0);
}
#vt-2:checked ~ .vt__nav .vt__indicator {
transform: translateY(36px);
}
#vt-3:checked ~ .vt__nav .vt__indicator {
transform: translateY(72px);
}
#vt-1:checked ~ .vt__nav .vt__trail {
transform: translateY(0);
}
#vt-2:checked ~ .vt__nav .vt__trail {
transform: translateY(36px);
}
#vt-3:checked ~ .vt__nav .vt__trail {
transform: translateY(72px);
}
#vt-1:checked ~ .vt__nav label[for=vt-1],
#vt-2:checked ~ .vt__nav label[for=vt-2],
#vt-3:checked ~ .vt__nav label[for=vt-3] {
color: #17141a;
}
.vt__panels {
position: relative;
display: grid;
flex: 1 1 auto;
min-width: 0;
}
.vt__panel {
grid-area: 1/1;
margin: 0;
color: #17141a;
font-weight: 400;
font-size: clamp(12px, 3.2vw, 13px);
line-height: 1.5;
font-family: inherit;
opacity: 0;
transition: opacity 300ms linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1);
}
#vt-1:checked ~ .vt__panels .vt__panel--1,
#vt-2:checked ~ .vt__panels .vt__panel--2,
#vt-3:checked ~ .vt__panels .vt__panel--3 {
opacity: 1;
}
.vt.is-demo .vt__indicator {
animation: vt-loop 2s linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1) infinite;
}
.vt.is-demo .vt__trail {
animation: vt-loop 2s linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1) infinite;
animation-delay: 0.12s;
}
.vt.is-demo .vt__panel--1 {
animation: vt-panel-1 2s linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1) infinite;
}
.vt.is-demo .vt__panel--2 {
animation: vt-panel-2 2s linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1) infinite;
}
.vt.is-demo .vt__panel--3 {
animation: vt-panel-3 2s linear(0, 0.051, 0.176, 0.341, 0.518, 0.685, 0.831, 0.947, 1.032, 1.087, 1.117, 1.126, 1.121, 1.105, 1.085, 1.062, 1.041, 1.022, 1.008, 0.997, 1) infinite;
}
@keyframes vt-loop {
0%, 15% {
transform: translateY(0);
}
33%, 48% {
transform: translateY(36px);
}
66%, 81% {
transform: translateY(72px);
}
100% {
transform: translateY(0);
}
}
@keyframes vt-panel-1 {
0%, 15% {
opacity: 1;
}
30%, 100% {
opacity: 0;
}
}
@keyframes vt-panel-2 {
0%, 30% {
opacity: 0;
}
45%, 63% {
opacity: 1;
}
78%, 100% {
opacity: 0;
}
}
@keyframes vt-panel-3 {
0%, 63% {
opacity: 0;
}
78%, 96% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.vt__indicator, .vt__panel, .vt__trail {
transition: none;
}
.vt.is-demo .vt__indicator,
.vt.is-demo .vt__panel--1,
.vt.is-demo .vt__panel--2,
.vt.is-demo .vt__panel--3,
.vt.is-demo .vt__trail {
animation: none !important;
}
.vt__trail {
opacity: 0;
}
}// 이동은 :checked 만으로 이미 동작한다. 실제 클릭이 오면 데모 루프(.is-demo)만 뗀다.
document.querySelectorAll('.vt__radio').forEach(function (r) {
r.addEventListener('pointerdown', function () { document.querySelector('.vt').classList.remove('is-demo'); });
});import { useState } from "react";
import type { CSSProperties } from "react";
import styles from "./VerticalTabs.module.scss";
const TABS = [
{ label: "계정", panel: "이름과 이메일을 바꿉니다." },
{ label: "알림", panel: "푸시·메일 알림을 고릅니다." },
{ label: "보안", panel: "비밀번호와 2단계 인증을 관리합니다." },
];
export type VerticalTabsProps = {
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string; "--i"?: number };
export default function VerticalTabs({ duration = 300, easing = "cubic-bezier(.2,.8,.2,1)", color = "#fff7e6" }: VerticalTabsProps) {
const [active, setActive] = useState(0);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color, "--i": active };
return (
<div className={styles.vt} style={vars}>
<div className={styles.nav} role="tablist">
<span className={styles.indicator} aria-hidden="true" />
{TABS.map((t, i) => (
<button key={t.label} type="button" role="tab" aria-selected={i === active}
className={styles.tab} onClick={() => setActive(i)}>
{t.label}
</button>
))}
</div>
<p className={styles.panel}>{TABS[active].panel}</p>
</div>
);
}07 縦タブ — 計測 累積面積 1.549% · 動いたフレーム 16/23GODRICH オリジナル · SCSS と React は zip に同梱 · CSS タブ 切り替え アニメーション9選 — JS最小・CSSだけ
このデモが属する記事
CSS タブ 切り替え アニメーション9選 — JS最小・CSSだけcss タブ 切り替え アニメーションは、ラジオボタンの:checked状態やrole="tablist"ボタンだけでインジケーターが滑り、パネルの中身が入れ替わる仕組みです。9個のうち7個はCSSだけで動きますが、矢印キー操作が要る2個だ この記事のデモをすべて見る


