Live preview · fully interactive
The prompt
Build a sidebar with a sliding indicator. ## Look Four text buttons, 14px, inactive #8a8a99, active #f2f2f7, padding-left 16px, gap 14px, fixed on the left and vertically centered. The mark is 3×16, radius 99px, #7c6cff. Page #08080d. Labels: Overview, Motion, Prompt, License. ## Behavior On click, translateY the mark to the button’s top. Toggle the active color. ## Design tokens - Mark #7c6cff; inactive #8a8a99; active #f2f2f7; page #08080d. ## Motion - Transform transition 0.3s, easing cubic-bezier(0.16, 1, 0.3, 1). ## Constraints - Single self-contained HTML file. No libraries. - Honor prefers-reduced-motion: reduce by skipping the loop and leaving a readable static frame - Readable at 390px width with no horizontal page scroll
The code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }
body {
background: #08080d; color: #f2f2f7; font-family: Inter, system-ui, sans-serif;
min-height: 100vh; overflow: hidden;
}
.hint { position: absolute; left: 16px; top: 16px; z-index: 5; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #8a8a99; }
body { overflow: hidden; } nav { position: fixed; left: 20px; top: 50%; transform: translateY(-50%); display: grid; gap: 14px; } button { border: 0; background: transparent; color: #8a8a99; text-align: left; font-size: 14px; cursor: pointer; padding-left: 16px; } button.on { color: #f2f2f7; } i { position: absolute; left: 20px; width: 3px; height: 16px; background: #7c6cff; border-radius: 99px; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
@media (max-width: 420px) {
.hint { font-size: 10px; letter-spacing: 0.08em; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
</style>
</head>
<body>
<i id="mark"></i><nav id="nav"><button class="on">Overview</button><button>Motion</button><button>Prompt</button><button>License</button></nav>
<script>
var mark = document.getElementById("mark");
var buttons = document.querySelectorAll("#nav button");
function place(btn) {
var y = btn.getBoundingClientRect().top + 2;
mark.style.transform = "translateY(" + y + "px)";
buttons.forEach(function (b) { b.classList.toggle("on", b === btn); });
}
buttons.forEach(function (b) { b.addEventListener("click", function () { place(b); }); });
place(buttons[0]);
</script>
</body>
</html>About this effect
Four section names stack on the left. Clicking one moves a 16px violet bar to that row over 0.3s and dims the others.