Skip to content

Story Tap-Through Progress

A copy-paste galleries & carousels component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

Galleries & CarouselsHTMLJavaScriptCSSany framework

Copy into your project

HTML
<div class="nuda-gc2-story-progress" role="group" aria-roledescription="carousel" aria-label="Story slideshow">
  <div class="nuda-gc2-story-progress__bars" aria-hidden="true">
    <span class="is-done"></span>
    <span class="is-active"><i></i></span>
    <span></span>
  </div>
  <div class="nuda-gc2-story-progress__stage" style="background:linear-gradient(150deg,#9d6dff,#ff6dd4)">
    <button type="button" class="nuda-gc2-story-progress__zone nuda-gc2-story-progress__zone--prev" aria-label="Previous story"></button>
    <button type="button" class="nuda-gc2-story-progress__zone nuda-gc2-story-progress__zone--next" aria-label="Next story"></button>
  </div>
</div>
JavaScript
const root = document.querySelector('.nuda-gc2-story-progress');
const bars = [...root.querySelectorAll('.nuda-gc2-story-progress__bars span')];
let i = bars.findIndex((b) => b.classList.contains('is-active'));

const render = (next) => {
  bars.forEach((b, n) => {
    b.className = n < next ? 'is-done' : n === next ? 'is-active' : '';
    if (n === next) b.innerHTML = '<i></i>';
  });
  i = next;
};

root.querySelector('.nuda-gc2-story-progress__zone--prev').addEventListener('click', () => render(Math.max(0, i - 1)));
root.querySelector('.nuda-gc2-story-progress__zone--next').addEventListener('click', () => render(Math.min(bars.length - 1, i + 1)));
CSS
.nuda-gc2-story-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 180px;
}

.nuda-gc2-story-progress__bars {
  display: flex;
  gap: 4px;
}

.nuda-gc2-story-progress__bars span {
  position: relative;
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: rgba(255,255,255,.2);
  overflow: hidden;
}

.nuda-gc2-story-progress__bars span.is-done {
  background: #fafafa;
}

.nuda-gc2-story-progress__bars span.is-active i {
  position: absolute;
  inset: 0;
  transform: scaleX(.4);
  transform-origin: left;
  background: #e4ff54;
  border-radius: 99px;
  animation: _nuda-gc2story-progress 5s linear infinite;
}

.nuda-gc2-story-progress__stage {
  position: relative;
  height: 180px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
}

.nuda-gc2-story-progress__zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nuda-gc2-story-progress__zone--prev {
  left: 0;
}

.nuda-gc2-story-progress__zone--next {
  right: 0;
}

.nuda-gc2-story-progress__zone:focus-visible {
  outline: 2px solid #e4ff54;
  outline-offset: -2px;
}

@keyframes _nuda-gc2story-progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@media (prefers-reduced-motion:reduce) {
  .nuda-gc2-story-progress__bars span.is-active i {
    animation: none;
    transform: scaleX(.4);
  }
}

How to use Story Tap-Through Progress

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More galleries & carousels components

← Browse all NudaUI components