Carousel

Quick start guide and documentation

5-Minute Setup

1 Include Files (Add to <head>)

Required Files • HTML



    



                    

2 Include JavaScript (Add before </body>)

Required JavaScript • HTML





                    

3 Create Basic Carousel

Basic Carousel • HTML


                    
✓ Done! Your carousel is now functional with keyboard navigation and smooth fade transitions.

Two Carousel Patterns

1. Basic Carousel (Simple Navigation)

Perfect for image galleries and product showcases with simple prev/next navigation

Code • HTML

2. Advanced Slider with Auto-Rotation & Indicators

Full-featured slideshow with numbered indicators, autoplay, and pause controls

Code • HTML

1
2
3

Quick Reference

Data Attributes

Attribute Purpose Values
data-auto-rotate Enable automatic slide rotation "true"
data-interval Rotation interval in seconds "3" (default), "5", etc.
data-slide-index Index for slide indicator buttons "0", "1", "2"...

CSS Classes

Class Purpose
.slider Main carousel container
.carousel Slides container
.carousel-slide Individual slide
.active Currently visible slide/indicator
.carousel-caption Caption overlay on slides
.carousel-prev-arrow Previous slide button
.carousel-next-arrow Next slide button
.slider-indicators Container for numbered indicators
.slider-indicator Individual numbered indicator
.pause-container Container for pause/play buttons

How It Works

The Carousel Mechanism:
  1. First slide is marked with .active class on page load
  2. JavaScript listens for prev/next arrow clicks and indicator clicks
  3. Active slide fades out while next slide fades in using CSS transitions
  4. Indicators update to show current slide position
  5. If data-auto-rotate="true", slides advance automatically
  6. Pause/play buttons stop and resume auto-rotation
  7. Keyboard users can navigate with Tab and Enter keys
⚠ Important: Always mark the first slide with class="carousel-slide active" and the first indicator with class="slider-indicator active" for proper initialization.

Pro Tips

✨ Tip 1: Use data-interval="5" for longer intervals—give users time to read captions
✨ Tip 2: Add .slider-indicators-scroll wrapper to enable horizontal scrolling for many indicators
✨ Tip 3: Captions are optional—omit .carousel-caption for image-only carousels
✨ Tip 4: Always include meaningful alt text for images for screen reader users
✨ Tip 5: Use pause controls if auto-rotation is enabled—some users need more time to process content

Troubleshooting

Carousel Not Advancing?

Auto-Rotation Not Working?

Indicators Not Clickable?

ADA Compliance Built-In

RSL Carousels are ADA-compliant by default:

  • ✅ Keyboard navigation through arrows and indicators
  • ✅ Pause/play controls for users who need more time
  • ✅ Captions provide context for screen reader users
  • ✅ Image alt text required for accessibility
  • ✅ Focus visible on navigation elements
  • ✅ Auto-rotation can be paused to prevent distraction

Next Steps

See It In Action

Open carousel.html for live demos

Customize Styling

Use custom CSS to match your brand colors and design

Advanced Features

Combine with modals for lightbox-style image viewing