Carousel

Slides with previous and next buttons, dots and optional autoplay.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrCarousel, WrCarouselSlide } from 'ngwr/carousel';

@Component({ imports: [WrCarousel, WrCarouselSlide] })
export class MyComponent {}

Basic

Give the carousel a height: the slides fill it. Autoplay pauses on hover and focus, and does not run while the reader prefers reduced motion.

<wr-carousel [(active)]="i" autoplay style="aspect-ratio: 16 / 9">
  <wr-carousel-slide>Slide 1</wr-carousel-slide>
  <wr-carousel-slide>Slide 2</wr-carousel-slide>
</wr-carousel>

API

NameDescriptionTypeDefault
prevLabelAccessible name of the previous-slide button. Falls back to carousel.prev.string | nullnull
nextLabelAccessible name of the next-slide button. Falls back to carousel.next.string | nullnull
paginationLabelAccessible name of the dot group. Falls back to carousel.pagination.string | nullnull
ariaLabelAccessible name of the carousel itself. Falls back to carousel.label.string | nullnull
roledescriptionWord a screen reader speaks IN PLACE OF the group role. Falls back to carousel.roledescription, then 'carousel'.string | nullnull
activeActive slide index. Two-way bindable.number0
showArrowsShow prev / next arrow buttons.booleantrue
showDotsShow dot indicators below the slides.booleantrue
autoplayAuto-advance slides. Held while the pointer or keyboard focus is inside the carousel and during a swipe, and does not run at all while the reader prefers reduced motion — followed live, so turning the setting on mid-session stops the slides and turning it off starts them.booleanfalse
intervalMsAutoplay interval (ms).number4000
loopWrap around at the ends.booleantrue

<wr-carousel-slide>

NameDescriptionTypeDefault
roledescriptionWord a screen reader speaks IN PLACE OF the group role. Falls back to carousel.slideRoledescription, then 'slide'.string | nullnull

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/carousel's own element.

VariableDefaultDeclared on
--wr-carousel-dot-active-radiusvar(--wr-border-radius-pill).wr-carousel
--wr-carousel-dots-gapvar(--wr-space-sm).wr-carousel
--wr-carousel-font-familyvar(--wr-font-family-base).wr-carousel

See also