webdevpuneet.com

Vertical Content Carousel — HTML CSS JS Snippet

Vertical Content Carousel · Carousels · Plain HTML, CSS & JS · Live preview

Copy & paste

Source Code

<div class="vcc-wrap">
  <button class="vcc-btn vcc-up" id="vccUp" aria-label="Previous">▲</button>
  <div class="vcc-viewport">
    <div class="vcc-track" id="vccTrack">
      <div class="vcc-slide" style="background:linear-gradient(160deg,#6366f1,#4338ca)"><span>🎧</span><h3>Headphones</h3></div>
      <div class="vcc-slide" style="background:linear-gradient(160deg,#0ea5e9,#0369a1)"><span>📷</span><h3>Camera</h3></div>
      <div class="vcc-slide" style="background:linear-gradient(160deg,#ec4899,#9d174d)"><span>⌚</span><h3>Watch</h3></div>
      <div class="vcc-slide" style="background:linear-gradient(160deg,#10b981,#047857)"><span>🎮</span><h3>Console</h3></div>
    </div>
  </div>
  <button class="vcc-btn vcc-down" id="vccDown" aria-label="Next">▼</button>
  <div class="vcc-dots" id="vccDots"></div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Every axis consistently swapped — translateY, a column-direction track, up/down controls, vertically-stacked dots
Active dot grows in height rather than width, matching the vertical dot column's own orientation
Swipe/drag detection compares vertical (clientY) deltas, correctly matching the vertical slide direction
Up/Down arrow key support, mirroring the vertical button controls
Same offset-driven percentage-transform mechanic used throughout this library's horizontal carousels
Unified pointer and touch handling for the vertical swipe gesture

About this UI Snippet

Vertical Content Carousel — Every Axis Swapped, Same Underlying Mechanic

Screenshot of the Vertical Content Carousel snippet rendered live

This is the same offset-driven slide mechanic used throughout this library's horizontal carousels, with every axis consistently swapped: translateX becomes translateY, the track is a flex-direction: column instead of a row, the up/down buttons replace left/right arrows, and even the indicator dots rotate to stack vertically and grow in *height* (not width) when active, so the whole visual language stays internally consistent with the vertical motion rather than just reusing horizontal styling with the transform swapped.

Why this needed a genuinely new snippet, not a CSS-only reskin

Swapping translateX for translateY in isolation is trivial — but the *drag/swipe direction* has to change too. A horizontal carousel's swipe logic compares clientX deltas; this one compares clientY deltas instead, since a vertical carousel should respond to an up/down finger or mouse drag, not a left/right one. Get that mismatched (vertical slides, horizontal swipe detection) and the carousel would visually move the wrong way relative to the gesture, which is a subtle, easy-to-miss bug when adapting a horizontal component rather than building the vertical version from its own first principles.

Dots that grow taller, not wider

The active dot indicator grows to height: 20px rather than width: 20px — a small but deliberate detail, since a horizontal pill-shaped active dot in a *vertical* stack of dots would look visually disconnected from the rest of the column, while a vertically-elongated one reads immediately as "this dot, in this vertical list, is the active one."

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA vertical carousel appears with up/down buttons and a column of dots beside it.
  2. 2
    Click the down arrowThe content slides upward to reveal the next item — motion runs vertically, not sideways.
  3. 3
    Click a dotJump directly to that slide; the active dot grows taller to mark its position in the column.
  4. 4
    Drag or swipe verticallySwipe up to advance, down to go back — gesture direction matches the slide direction.
  5. 5
    Use Up/Down arrow keysFull keyboard control, matching the carousel's vertical orientation.

Real-world uses

Common Use Cases

Sidebar or narrow-column content rotators
Vertical motion fits naturally into a tall, narrow UI region where horizontal space is limited.
News ticker or update feed panels
A vertically-scrolling content panel matches how a feed or ticker is conventionally read.
Dashboard widget rotators
Cycle through several stats or alerts in a compact vertical widget slot.
Learning to adapt a horizontal component to a new axis
A clear reference for what genuinely needs to change (not just the transform) when flipping orientation.

Got questions?

Frequently Asked Questions

More than just the transform axis — the track's flex-direction, the indicator dots' growth axis, and critically the swipe/drag gesture detection (comparing clientY instead of clientX) all need to change together, or the carousel will visually move inconsistently with the gesture driving it.

Change .vcc-viewport's fixed height and each .vcc-slide's matching flex-basis/height together — they must stay equal or slides will show partial neighbors or leave gaps.

Not directly — auto-height measures and animates the container's height to fit content, which conflicts with this snippet's fixed-height vertical viewport. For variable-height vertical slides, you'd need a hybrid that measures height while still tracking translateY offsets carefully.

Without a minimum distance threshold, a small accidental mouse movement or a light tap could unintentionally trigger a slide change — the threshold distinguishes a deliberate swipe gesture from incidental pointer movement.

Up/down buttons are real labeled buttons, dots are labeled and clickable, and Up/Down arrow keys provide full keyboard navigation matching the visual orientation.