Rate this docs

Angular Bootstrap Carousel

Angular Carousel - Bootstrap 4 & Material Design

A slideshow component for cycling through elements—images or slides of text—like a carousel.


How it works

The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators.

In browsers where the Page Visibility API is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).

Please be aware that nested carousels are not supported, and carousels are generally not compliant with accessibility standards.


Example

Carousels don’t automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they’re not explicitly required. Add and customize as you see fit.

Slides only

Here’s a carousel with slides only. Note the presence of the .d-block and .w-100 on carousel images to prevent browser default image alignment.



        <mdb-carousel [isControls]="false" [animation]="'slide'">
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(130).jpg" alt="First slide">
          </mdb-carousel-item>
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(129).jpg" alt="Second slide">
          </mdb-carousel-item>
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(70).jpg" alt="Third slide">
          </mdb-carousel-item>
        </mdb-carousel>

      

With controls and indicators

Adding in the previous and next controls, and the slides indicator:



        <mdb-carousel [animation]="'slide'">
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(130).jpg" alt="First slide">
          </mdb-carousel-item>
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(129).jpg" alt="Second slide">
          </mdb-carousel-item>
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(70).jpg" alt="Third slide">
          </mdb-carousel-item>
        </mdb-carousel>

      

With captions

Add captions to your slides easily with the .carousel-caption element within any mdb-carousel-item. They can be easily hidden on smaller viewports, as shown below, with optional display utilities. We hide them initially with .d-none and bring them back on medium-sized devices with .d-md-block.

If your content is not visible enough, you can cover the image with a darker mask.

You can easily change the intensity and color of the mask. To learn more read our MASKS documentation.


        <mdb-carousel class="carousel slide carousel-fade" [animation]="'fade'">
          <mdb-carousel-item>
            <div class="view w-100">
              <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(68).jpg" alt="First slide">
              <div class="mask rgba-black-light waves-light" mdbWavesEffect></div>
            </div>
            <div class="carousel-caption">
              <h3 class="h3-responsive">Light mask</h3>
              <p>First text</p>
            </div>
          </mdb-carousel-item>
          <mdb-carousel-item>
            <div class="view w-100">
              <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(6).jpg" alt="Second slide">
              <div class="mask rgba-black-strong waves-light" mdbWavesEffect></div>
            </div>
            <div class="carousel-caption">
              <h3 class="h3-responsive">Strong mask</h3>
              <p>Secondary text</p>
            </div>
          </mdb-carousel-item>
          <mdb-carousel-item>
            <div class="view w-100">
              <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(9).jpg" alt="Third slide">
              <div class="mask rgba-black-slight waves-light" mdbWavesEffect></div>
            </div>
            <div class="carousel-caption">
              <h3 class="h3-responsive">Slight mask</h3>
              <p>Third text</p>
            </div>
          </mdb-carousel-item>
        </mdb-carousel>
      

Crossfade

Add .carousel-fade and [animation]="'fade'" to your carousel to animate slides with a fade transition instead of a slide.


        <mdb-carousel class="carousel slide carousel-fade" [animation]="'fade'">
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(68).jpg" alt="First slide">
          </mdb-carousel-item>
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(6).jpg" alt="Second slide">
          </mdb-carousel-item>
          <mdb-carousel-item>
            <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(9).jpg" alt="Third slide">
          </mdb-carousel-item>
        </mdb-carousel>
      



Video carousel



        <mdb-carousel class="carousel slide carousel-fade" [animation]="'fade'">
          <mdb-carousel-item>
            <video class="video-fluid" autoplay loop muted>
              <source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
            </video>
          </mdb-carousel-item>
          <mdb-carousel-item>
            <video class="video-fluid" autoplay loop muted>
              <source src="https://mdbootstrap.com/img/video/forest.mp4" type="video/mp4" />
            </video>
          </mdb-carousel-item>
          <mdb-carousel-item>
            <video class="video-fluid" autoplay loop muted>
              <source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
            </video>
          </mdb-carousel-item>
        </mdb-carousel>

      

Caption and mask

If you want to add a caption to your carousel you will probably also need to cover it with a dark mask, to make your caption more visible.

You can easily change the intensity and color of the mask. To learn more read our MASKS documentation.



        <mdb-carousel [isControls]="true" class="carousel slide" [animation]="'slide'">
          <mdb-carousel-item>
            <div class="view">
              <video class="video-fluid" autoplay loop>
                <source src="https://mdbootstrap.com/img/video/Lines.mp4" type="video/mp4" />
              </video>
              <div class="mask rgba-indigo-light waves-light" mdbWavesEffect></div>
            </div>

            <div class="carousel-caption">
              <div class="animated fadeInDown">
                <h3 class="h3-responsive">Light mask</h3>
                <p>First text</p>
              </div>
            </div>
          </mdb-carousel-item>
          <mdb-carousel-item>
            <div class="view">
              <video class="video-fluid" autoplay loop>
                <source src="https://mdbootstrap.com/img/video/animation-intro.mp4" type="video/mp4" />
              </video>
              <div class="mask rgba-purple-slight waves-light" mdbWavesEffect></div>
            </div>

            <div class="carousel-caption">
              <div class="animated fadeInDown">
                <h3 class="h3-responsive">Super light mask</h3>
                <p>Secondary text</p>
              </div>
            </div>
          </mdb-carousel-item>
          <mdb-carousel-item>
            <div class="view">
              <video class="video-fluid" autoplay loop>
                <source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
              </video>
              <div class="mask rgba-black-strong waves-light" mdbWavesEffect></div>
            </div>

            <div class="carousel-caption">
              <div class="animated fadeInDown">
                <h3 class="h3-responsive">Strong mask</h3>
                <p>Third text</p>
              </div>
            </div>
          </mdb-carousel-item>
        </mdb-carousel>

      

Angular Carousel - API

In this section you will find informations about required modules and available inputs, outputs, methods and events of carousel component.


Modules used

In order to speed up your application, you can choose to import only the modules you actually need, instead of importing the entire MDB Angular library. Remember that importing the entire library, and immediately afterwards a specific module, is bad practice, and can cause application errors.

// For MDB Angular Pro
import { CarouselModule, WavesModule } from 'ng-uikit-pro-standard'
// For MDB Angular Free
import { CarouselModule, WavesModule } from 'angular-bootstrap-md'

Components

CarouselComponent

Selector: mdb-carousel

Type: CarouselComponent


Inputs

Name Type Default Description Example
interval number 5000 The amount of time to delay between automatically cycling an item. If 0, carousel will not automatically cycle. [interval]="'0'"
noPause boolean false No pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. [noPause]="true"
noWrap boolean false Whether the carousel should cycle continuously or have hard stops. [noWrap]="true"
keyboard boolean true Whether the carousel should react to keyboard events. [keyboard]="false"
activeSlideIndex number 0 Index of currently displayed slide (started for 0). You can tell carousel from which one slide start. (two way binding [(activeSlideIndex)] ) [activeSlideIndex]="1"
isControls boolean true If set to false, carousel won't show next / previous buttons. [isControls]="false"

Methods

Below methods are available in CarouselComponent

Name Description
play() Cycles through the carousel items from left to right.
pause() Stops the carousel from cycling through items.
selectSlide(number) Cycles the carousel to a particular frame (0 based, similar to an array).
previousSlide() Cycles to the previous item.
nextSlide() Cycles to the next item.

Events

Name Type Description Example
activeSlideChange any Will be emitted when active slide has been changed (activeSlideChange)="onActiveSlideChange($event)"