Sign in


Sign up


Angular Bootstrap Carousel (slider)

MDB gives you a possibility to present your images, videos, and text messages in much more eye-pleasant form by providing you with few stunning carousels.

Each carousel is fully responsive and works perfectly on any device or browser.


Basic example

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

Optional captions

Add captions to your slides easily with the .carousel-caption element within any slide. Place just about any optional HTML within there and it will be automatically aligned and formatted.

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.

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

Multi-item carousel MDB Pro component

                        
<!--Carousel Wrapper-->
<mdb-carousel class="carousel-multi-item multi-animation" [type]="'carousel-multi-item'" [animation]="'slide'">
    <!--First slide-->
    <mdb-slide>
        <div class="col-md-4">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>
        <div class="col-md-4 clearfix d-none d-md-block">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(18).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>
        <div class="col-md-4 clearfix d-none d-md-block">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(35).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>    
    </mdb-slide>
    <!--/First slide-->
    <!--Second slide-->
    <mdb-slide>
        <div class="col-md-4">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(60).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>
        <div class="col-md-4 clearfix d-none d-md-block">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(47).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>
        <div class="col-md-4 clearfix d-none d-md-block">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(48).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>    
    </mdb-slide>
    <!--/Second slide-->
    <!--Third slide-->
    <mdb-slide>
        <div class="col-md-4">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(53).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>
        <div class="col-md-4 clearfix d-none d-md-block">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(45).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>
        <div class="col-md-4 clearfix d-none d-md-block">
            <div class="card">
                <img class="img-fluid" src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(51).jpg" alt="Card image cap">
                <div class="card-body">
                    <h4 class="card-title">Card title</h4>
                    <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                    <a href="#" class="btn btn-primary waves-light" mdbRippleRadius>Button</a>
                </div>
            </div>
        </div>    
    </mdb-slide>
    <!--/Third slide-->
</mdb-carousel>
<!--/.Carousel Wrapper-->
                        
                        

Thumbnails carousel MDB Pro component

                        
<!--Carousel Wrapper-->
<mdb-carousel class="carousel slide carousel-fade" [type]="'carousel-thumbnails'" [animation]="'fade'">
    <!--First slide-->
    <mdb-slide>
        <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(88).jpg" alt="First slide">
    </mdb-slide>
    <!--/First slide-->
    <!--Second slide-->
    <mdb-slide>
        <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(121).jpg" alt="Second slide">
    </mdb-slide>
    <!--/Second slide-->
    <!--Third slide-->
    <mdb-slide>
        <img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(31).jpg" alt="Third slide">
    </mdb-slide>
    <!--/Third slide-->
</mdb-carousel>
<!--/.Carousel Wrapper-->
                        
                        

Video Carousel

                        
<!--Carousel Wrapper-->
<mdb-carousel class="carousel slide carousel-fade" [animation]="'fade'">
    <!--First slide-->
    <mdb-slide>
        <video class="video-fluid" autoplay loop>
            <source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
        </video>
    </mdb-slide>
    <!--/First slide-->
    <!--Second slide-->
    <mdb-slide>
        <video class="video-fluid" autoplay loop>
            <source src="https://mdbootstrap.com/img/video/forest.mp4" type="video/mp4" />
        </video>
    </mdb-slide>
    <!--/Second slide-->
    <!--Third slide-->
    <mdb-slide>
        <video class="video-fluid" autoplay loop>
            <source src="https://mdbootstrap.com/img/video/Agua-natural.mp4" type="video/mp4" />
        </video>
    </mdb-slide>
    <!--/Third slide-->
</mdb-carousel>
<!--Carousel Wrapper-->
                        
                        

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.

                            
<!--Carousel Wrapper-->
<mdb-carousel class="carousel slide" [animation]="'slide'">
    <!--First slide-->
    <mdb-slide>
        <!--Mask color-->
        <div class="view hm-indigo-light">
            <!--Video source-->
            <video class="video-fluid" autoplay loop>
                <source src="https://mdbootstrap.com/img/video/Lines.mp4" type="video/mp4" />
            </video>
            <div class="mask waves-light" mdbRippleRadius></div>
        </div>

        <!--Caption-->
        <div class="carousel-caption">
            <div class="animated fadeInDown">
                <h3 class="h3-responsive">Light mask</h3>
                <p>First text</p>
            </div>
        </div>
        <!--Caption-->
    </mdb-slide>
    <!--/First slide-->
    <!--Second slide-->
    <mdb-slide>
        <!--Mask color-->
        <div class="view hm-purple-slight">
            <!--Video source-->
            <video class="video-fluid" autoplay loop>
                <source src="https://mdbootstrap.com/img/video/animation-intro.mp4" type="video/mp4" />
            </video>
            <div class="mask waves-light" mdbRippleRadius></div>
        </div>

        <!--Caption-->
        <div class="carousel-caption">
            <div class="animated fadeInDown">
                <h3 class="h3-responsive">Super light mask</h3>
                <p>Secondary text</p>
            </div>
        </div>
        <!--Caption-->
    </mdb-slide>
    <!--/Second slide-->
    <!--Third slide-->
    <mdb-slide>
        <!--Mask color-->
        <div class="view hm-black-strong">
            <!--Video source-->
            <video class="video-fluid" autoplay loop>
                <source src="https://mdbootstrap.com/img/video/cube.mp4" type="video/mp4" />
            </video>
            <div class="mask waves-light" mdbRippleRadius></div>
        </div>

        <!--Caption-->
        <div class="carousel-caption">
            <div class="animated fadeInDown">
                <h3 class="h3-responsive">Strong mask</h3>
                <p>Third text</p>
            </div>
        </div>
        <!--Caption-->
    </mdb-slide>
    <!--/Third slide-->
</mdb-carousel>
<!--Carousel Wrapper-->
                            
                            

Full page carousels

Click the buttons below to see a live preview.

Full Image Carousel Full Video Carousel

Slide/Fade

Add a [animation] tag with slide or fade option to manipulate the effect.

                        
// Fade Animation
<mdb-carousel class="carousel slide carousel-fade" [animation]="'fade'">

// Slide Animation
<mdb-carousel class="carousel slide" [animation]="'slide'">
                        
                        

Options

Options can be passed via directive or providers. For directive, append the option name to [...].

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

Methods

To use methods, add the following refference to the carousel element.


<mdb-carousel #carouselRef></mdb-carousel>

<a (click)="carouselRef.nextSlide()">Next</a>
            
.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

Bootstrap’s carousel class provides one event for hooking into carousel functionality:

All carousel events are fired at the carousel itself (i.e. at the <div class="carousel">).

Event Type Description
activeSlideChange Will be emitted when active slide has been changed

<div class="fixed-sn">
    <div class="col-lg-10 ml-auto mr-auto">
        <mdb-carousel [interval]="myInterval" [noWrap]="noWrapSlides" [(activeSlide)]="activeSlideIndex" (activeSlideChange)="activeSlideChange()">
          <mdb-slide *ngFor="let slide of slides; let index=index">
            <img [src]="slide.image">
            <div class="carousel-caption">
              <h4>Slide {{index}}</h4>
              <p>{{slide.text}}</p>
            </div>
          </mdb-slide>
        </mdb-carousel>
    </div>
</div>
        

Data structure:


import { Component } from '@angular/core';

@Component({
  selector: 'carousel-example',
  templateUrl: 'carousel-example.html',
})

export class CarouselExampleComponent {

    public myInterval: number = 3000;
    public activeSlideIndex: number = 0;
    public noWrapSlides:boolean = false;

    activeSlideChange(){
        console.log(this.activeSlideIndex);
    }

    public slides:Array<Object> = [
        {"image":"https://mdbootstrap.com/img/Photos/Slides/img%20(18).jpg"},
        {"image":"https://mdbootstrap.com/img/Photos/Slides/img%20(19).jpg"},
        {"image":"https://mdbootstrap.com/img/Photos/Slides/img%20(20).jpg"},
    ];

}