Skip to content

Peek-Next Carousel

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-peek-next" role="group" aria-roledescription="carousel" aria-label="Peek carousel">
  <div class="nuda-gc2-peek-next__viewport">
    <div class="nuda-gc2-peek-next__slide" role="group" aria-roledescription="slide" aria-label="1 of 4" style="background:linear-gradient(135deg,#9d6dff,#ff6dd4)"></div>
    <!-- More slides -->
  </div>
  <div class="nuda-gc2-peek-next__nav">
    <button type="button" class="nuda-gc2-peek-next__btn" aria-label="Previous slide">
      <svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M15 18l-6-6 6-6" stroke="#fafafa" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>
    </button>
    <button type="button" class="nuda-gc2-peek-next__btn" aria-label="Next slide">
      <svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M9 18l6-6-6-6" stroke="#fafafa" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>
    </button>
  </div>
</div>
JavaScript
const root = document.querySelector('.nuda-gc2-peek-next');
const viewport = root.querySelector('.nuda-gc2-peek-next__viewport');
const [prevBtn, nextBtn] = root.querySelectorAll('.nuda-gc2-peek-next__btn');
const step = () => viewport.querySelector('.nuda-gc2-peek-next__slide').offsetWidth + 10;

prevBtn.addEventListener('click', () => viewport.scrollBy({ left: -step(), behavior: 'smooth' }));
nextBtn.addEventListener('click', () => viewport.scrollBy({ left: step(), behavior: 'smooth' }));
CSS
.nuda-gc2-peek-next {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 260px;
}

.nuda-gc2-peek-next__viewport {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 8px;
  padding: 2px 40px 2px 8px;
  scrollbar-width: none;
}

.nuda-gc2-peek-next__viewport::-webkit-scrollbar {
  display: none;
}

.nuda-gc2-peek-next__slide {
  flex: 0 0 82%;
  height: 120px;
  border-radius: 12px;
  scroll-snap-align: start;
  border: 1px solid rgba(255,255,255,.08);
}

.nuda-gc2-peek-next__nav {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.nuda-gc2-peek-next__btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #161616;
  border: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .25s,transform .2s;
}

.nuda-gc2-peek-next__btn:hover {
  background: #1e1e1e;
  transform: translateY(-1px);
}

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

@media (prefers-reduced-motion:reduce) {
  .nuda-gc2-peek-next__viewport {
    scroll-behavior: auto;
  }
}

How to use Peek-Next Carousel

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