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 [isControls]="true" [animation]="'slide'">
<!--First 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>
<!--/First slide-->
<!--Second slide-->
<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>
<!--/Second slide-->
<!--Third slide-->
<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>
<!--/Third slide-->
</mdb-carousel>
<!--/.Carousel Wrapper-->
Multi-item carousel MDB Pro component
<!--Carousel Wrapper-->
<mdb-carousel [isControls]="true" class="carousel-multi-item multi-animation" [type]="'carousel-multi-item'" [animation]="'slide'">
<!--First slide-->
<mdb-carousel-item>
<div class="col-md-4">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
<div class="col-md-4 clearfix d-none d-md-block">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(35).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
<div class="col-md-4 clearfix d-none d-md-block">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(60).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
</mdb-carousel-item>
<!--/First slide-->
<!--Second slide-->
<mdb-carousel-item>
<div class="col-md-4">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(47).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
<div class="col-md-4 clearfix d-none d-md-block">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(48).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
<div class="col-md-4 clearfix d-none d-md-block">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(53).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
</mdb-carousel-item>
<!--/Second slide-->
<!--Third slide-->
<mdb-carousel-item>
<div class="col-md-4">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(45).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
<div class="col-md-4 clearfix d-none d-md-block">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(51).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
<div class="col-md-4 clearfix d-none d-md-block">
<mdb-card>
<mdb-card-img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).jpg" alt="Card image cap"></mdb-card-img>
<mdb-card-body>
<mdb-card-title>
<h4>Card title</h4>
</mdb-card-title>
<p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" mdbBtn color="primary" class="waves-light" mdbWavesEffect>Button</a>
</mdb-card-body>
</mdb-card>
</div>
</mdb-carousel-item>
<!--/Third slide-->
</mdb-carousel>
<!--/.Carousel Wrapper-->
Thumbnails carousel MDB Pro component
<!--Carousel Wrapper-->
<mdb-carousel [isControls]="true" class="carousel slide carousel-fade" [type]="'carousel-thumbnails'" [animation]="'fade'">
<!--First slide-->
<mdb-carousel-item>
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(88).jpg" alt="First slide">
</mdb-carousel-item>
<!--/First slide-->
<!--Second slide-->
<mdb-carousel-item>
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(121).jpg" alt="Second slide">
</mdb-carousel-item>
<!--/Second slide-->
<!--Third slide-->
<mdb-carousel-item>
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(31).jpg" alt="Third slide">
</mdb-carousel-item>
<!--/Third slide-->
</mdb-carousel>
<!--/.Carousel Wrapper-->
Video Carousel
<!--Carousel Wrapper-->
<mdb-carousel [isControls]="true" class="carousel slide carousel-fade" [animation]="'fade'">
<!--First slide-->
<mdb-carousel-item>
<video class="video-fluid" autoplay loop>
<source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
</video>
</mdb-carousel-item>
<!--/First slide-->
<!--Second slide-->
<mdb-carousel-item>
<video class="video-fluid" autoplay loop>
<source src="https://mdbootstrap.com/img/video/forest.mp4" type="video/mp4" />
</video>
</mdb-carousel-item>
<!--/Second slide-->
<!--Third slide-->
<mdb-carousel-item>
<video class="video-fluid" autoplay loop>
<source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
</video>
</mdb-carousel-item>
<!--/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 [isControls]="true" class="carousel slide" [animation]="'slide'">
<!--First slide-->
<mdb-carousel-item>
<!--Mask color-->
<div class="view">
<!--Video source-->
<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>
<!--Caption-->
<div class="carousel-caption">
<div class="animated fadeInDown">
<h3 class="h3-responsive">Light mask</h3>
<p>First text</p>
</div>
</div>
<!--Caption-->
</mdb-carousel-item>
<!--/First slide-->
<!--Second slide-->
<mdb-carousel-item>
<!--Mask color-->
<div class="view">
<!--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 rgba-purple-slight waves-light" mdbWavesEffect></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-carousel-item>
<!--/Second slide-->
<!--Third slide-->
<mdb-carousel-item>
<!--Mask color-->
<div class="view">
<!--Video source-->
<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>
<!--Caption-->
<div class="carousel-caption">
<div class="animated fadeInDown">
<h3 class="h3-responsive">Strong mask</h3>
<p>Third text</p>
</div>
</div>
<!--Caption-->
</mdb-carousel-item>
<!--/Third slide-->
</mdb-carousel>
<!--Carousel Wrapper-->
Full page carousels
Click the buttons below to see a live preview.
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. |
activeSlideIndex | number | 0 | Index of currently displayed slide (started for 0). You can tell carousel from which one slide start. (two way binding [(activeSlideIndex)] ) |
isControls | boolean | true | If set to false, carousel won't show next / previous buttons. Note, that [isControls] is REQUIRED. |
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 |
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(event: any){
console.log(event);
}
public slides:Array
API Reference:
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.
API Reference for MDB Angular Carousel:
// For MDB Angular Pro
import { CarouselModule, WavesModule, ButtonsModule } from 'ng-uikit-pro-standard'
// For MDB Angular Free
import { CarouselModule, WavesModule, ButtonsModule } from 'angular-bootstrap-md'