Carousel

An image/content slider with navigation arrows, dot indicators, autoplay, keyboard support, and captions.

InputTypeDefaultDescription
slidesNgOatCarouselSlide[][]Array of slide data (src, alt, title, description)
slideCountnumber0Total slides (for projected content)
autoplaybooleanfalseAuto-advance slides
intervalnumber5000Autoplay interval (ms)
loopbooleantrueLoop back after last slide
showArrowsbooleantrueShow prev/next buttons
showDotsbooleantrueShow dot indicators
dotsOverlaybooleanfalseOverlay dots on slides
showCaptionsbooleantrueShow slide captions
aspectRatio'auto' | '16:9' | '4:3' | '1:1''auto'Aspect ratio constraint
pauseOnHoverbooleantruePause autoplay on hover/focus
activeIndexnumber0Two-way bound active slide index
ariaLabelstring'Image carousel'Accessible label

Import & Usage

typescript
import { Component } from '@angular/core';
import { NgOatCarousel, type NgOatCarouselSlide } from '@letsprogram/ng-oat';

@Component({
  selector: 'app-example',
  imports: [NgOatCarousel],
  template: `
    <ng-oat-carousel
      [slides]="slides"
      [autoplay]="true"
      [interval]="5000"
      aspectRatio="16:9" />
  `,
})
export class ExampleComponent {
  slides: NgOatCarouselSlide[] = [
    { src: 'https://picsum.photos/800/450', alt: 'Slide 1', title: 'Hello' },
    { src: 'https://picsum.photos/800/451', alt: 'Slide 2' },
  ];
}

Basic Carousel

html
<ng-oat-carousel [slides]="slides" aspectRatio="16:9" />

// slides: NgOatCarouselSlide[] = [
//   { src: 'photo1.jpg', alt: 'Photo 1' },
//   { src: 'photo2.jpg', alt: 'Photo 2' },
// ];

With Captions

html
<ng-oat-carousel [slides]="slides" aspectRatio="16:9" [dotsOverlay]="true" />

// slides include title & description for captions

Autoplay

Pauses on hover/focus. Interval: 3 seconds.

html
<ng-oat-carousel [slides]="slides" [autoplay]="true" [interval]="3000" aspectRatio="16:9" />

No Loop (finite)

Arrows disable at the first and last slide.

html
<ng-oat-carousel [slides]="slides" [loop]="false" aspectRatio="16:9" />

Minimal (no arrows, dots only)

html
<ng-oat-carousel [slides]="slides" [showArrows]="false" aspectRatio="16:9" />

Controlled Index

Active index: 0

html
<ng-oat-carousel [slides]="slides" [(activeIndex)]="currentIndex" />
<button (click)="currentIndex.set(0)">Slide 1</button>

Aspect Ratios

4:3

1:1

html
<ng-oat-carousel [slides]="slides" aspectRatio="4:3" />
<ng-oat-carousel [slides]="slides" aspectRatio="1:1" />

Projected Content

html
<ng-oat-carousel [slideCount]="3">
  <div class="carousel-slide">Custom Slide 1</div>
  <div class="carousel-slide">Custom Slide 2</div>
  <div class="carousel-slide">Custom Slide 3</div>
</ng-oat-carousel>

Keyboard Navigation

Focus the carousel and use ← → arrow keys to navigate between slides.


Card Carousel

A horizontal scrollable product carousel with navigation arrows, "See All" link, and mobile touch scroll.

InputTypeDefaultDescription
headingstring''Section heading text
itemsNgOatProductCard[][]Array of product card data
showSeeAllbooleantrueShow the "See All" button
scrollAmountnumber0Custom px to scroll (0 = auto)
ariaLabelstring'Product carousel'Accessible label

Product Carousel

html
<ng-oat-card-carousel
  heading="Featured Products"
  [items]="products"
  (seeAllClick)="onSeeAll()"
  (cardClick)="onCardClick($event)"
/>

Without "See All"

html
<ng-oat-card-carousel
  heading="New Arrivals"
  [items]="products"
  [showSeeAll]="false"
/>

Many Cards (scrollable)

html
<ng-oat-card-carousel
  heading="All Products"
  [items]="products"
  ariaLabel="Full product catalog"
/>

Mobile Touch Scroll

On mobile (<768px) the nav arrows hide and the track becomes touch-scrollable with scroll-snap.