CSS Carousel Dots

Slide indicator dots where the active one stretches into a pill. Built on radio buttons, so it works with the keyboard.

  • dots
  • carousel
  • slider
  • indicator
  • pagination
  • radio
HTML
<div class="carousel-dots" role="radiogroup" aria-label="Slides">
  <input type="radio" name="slide" aria-label="Slide 1" checked>
  <input type="radio" name="slide" aria-label="Slide 2">
  <input type="radio" name="slide" aria-label="Slide 3">
  <input type="radio" name="slide" aria-label="Slide 4">
</div>
CSS
.carousel-dots {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: #f1f5f9;
}

.carousel-dots input {
  width: 10px;
  height: 10px;
  margin: 0;
  border-radius: 999px;
  background: #cbd5e1;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease;
}

.carousel-dots input:hover {
  background: #94a3b8;
}

.carousel-dots input:checked {
  width: 28px;
  background: #0f172a;
}

.carousel-dots input:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

About this CSS Carousel Dots

This CSS Carousel Dots is 33 lines of pure CSS (0.6 KB) with no JavaScript and no dependencies. It uses transitions, Flexbox, the :checked state (no JavaScript) and keyboard focus styles. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #f1f5f9
  • #cbd5e1
  • #94a3b8
  • #0f172a
  • #0ea5e9

How to use this carousel dots

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .carousel-dots class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback