Navigators and indicators in Vue Carousel component
11 Jun 202424 minutes to read
The navigators and indicators are used to transition the slides manually.
Navigators
Show or hide previous and next button
In navigators, the previous and next slide transition buttons are used to perform slide transitions manually. You can show/hide the navigators using the buttonsVisibility
property. The possible property values are as follows:
-
Hidden
– the navigator’s buttons are not visible. -
Visible
– the navigator’s buttons are visible. -
VisibleOnHover
– the navigator’s buttons are visible only when hovering over the carousel.
The following example depicts the code to show/hide the navigators in the carousel.
<template>
<div class="control-container">
<ejs-carousel buttonsVisibility="Visible">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel buttonsVisibility="Visible">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Show previous and next button on hover
In the carousel, you can show the previous and next buttons only on mouse hover using the buttonsVisibility
property. The following example depicts the code to show the navigators on mouse hover in the carousel.
<template>
<div class="control-container">
<ejs-carousel buttonsVisibility="VisibleOnHover">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel buttonsVisibility="VisibleOnHover">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Previous and next button template
Template options are provided to customize the previous button using previousButtonTemplate
and the next button using nextButtonTemplate
. The following example depicts the code for applying the template to previous and next buttons in the carousel.
<template>
<div class="control-container">
<ejs-carousel :previousButtonTemplate="'previousTemplate'" :nextButtonTemplate="'nextTemplate'">
<template v-slot:previousTemplate>
<ejs-button cssClass="e-flat e-round" iconCss="e-icons e-chevron-left-double"></ejs-button>
</template>
<template v-slot:nextTemplate>
<ejs-button cssClass="e-flat e-round" iconCss="e-icons e-chevron-right-double"></ejs-button>
</template>
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :previousButtonTemplate="'previousTemplate'" :nextButtonTemplate="'nextTemplate'">
<template v-slot:previousTemplate>
<ejs-button cssClass="e-flat e-round" iconCss="e-icons e-chevron-left-double"></ejs-button>
</template>
<template v-slot:nextTemplate>
<ejs-button cssClass="e-flat e-round" iconCss="e-icons e-chevron-right-double"></ejs-button>
</template>
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"ejs-button": ButtonComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Indicators
Show or hide indicators
In indicators, the total slides and current slide state have been depicted. You can show/hide the indicators using the showIndicators
property. The following example depicts the code to show/hide the indicators in the carousel.
<template>
<div class="control-container">
<ejs-carousel :showIndicators="true">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :showIndicators="true">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
},
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Indicators Template
Template option is provided to customize the indicators by using the indicatorTemplate
property. The following example depicts the code for applying a template to indicators in the carousel.
<template>
<div class="control-container">
<ejs-carousel :indicatorsTemplate="'indicatorsTemplate'">
<template v-slot:indicatorsTemplate>
<div class="indicator" indicator-index="{data.index}">
</div>
</template>
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar.e-template .indicator {
background-color: #ececec;
border-radius: 0.25rem;
cursor: pointer;
height: 0.5rem;
margin: 0.5rem;
width: 1.5rem;
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar.e-active .indicator {
background-color: #3c78ef;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :indicatorsTemplate="'indicatorsTemplate'">
<template v-slot:indicatorsTemplate>
<div class="indicator" indicator-index="{data.index}">
</div>
</template>
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar.e-template .indicator {
background-color: #ececec;
border-radius: 0.25rem;
cursor: pointer;
height: 0.5rem;
margin: 0.5rem;
width: 1.5rem;
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar.e-active .indicator {
background-color: #3c78ef;
}
</style>
Showing preview of slide in indicator
You can customize the indicators by showing the preview image of each slide using the indicatorTemplate
property. The following example depicts the code for showing the preview image using a template for indicators in the carousel.
<template>
<div class="control-container">
<ejs-carousel :indicatorsTemplate="indicatorsTemplate">
<e-carousel-items>
<e-carousel-item template="<div class='slide-content'>Slide 1</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 2</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 3</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 4</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 5</div>"></e-carousel-item>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
import { createApp } from 'vue';
var indicatorsVue = createApp().component("indicators", {
data() { return {} },
template: `<div class="indicator" indicator-index="{data.index}">
<div class="preview-content"></div>
</div>`,
computed: {},
methods: {
getContent: function (index) {
var slides = ["Slide 1", "Slide 2", "Slide 3", "Slide 4", "Slide 5"];
return slides[index];
},
},
});
var indicatorsTemplate = () => {
return {
template: indicatorsVue
};
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.e-carousel {
background-color: #adb5bd;
height: 300px !important;
margin: 0 auto;
width: 500px !important;
}
.e-carousel .slide-content {
align-items: center;
display: flex;
font-size: 1.25rem;
height: 100%;
justify-content: center;
}
.e-carousel .e-carousel-items,
.e-carousel .e-carousel-navigators {
height: calc(100% - 3rem);
}
.e-carousel .e-carousel-navigators .e-previous,
.e-carousel .e-carousel-navigators .e-next,
.e-carousel .e-carousel-navigators .nav-btn {
padding: 0;
}
.e-carousel .e-carousel-navigators .nav-btn:active,
.e-carousel .e-carousel-navigators .nav-btn:focus,
.e-carousel .e-carousel-navigators .nav-btn:hover {
background-color: transparent !important;
color: inherit;
}
.e-carousel .e-carousel-navigators svg {
fill: none;
stroke: currentColor;
stroke-linecap: square;
stroke-width: 8px;
height: 2rem;
vertical-align: middle;
width: 2rem;
}
.e-carousel .e-carousel-navigators .e-previous svg {
transform: rotate(180deg);
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar .indicator {
background-color: #adb5bd;
border: 1px solid black;
border-radius: 0.25rem;
cursor: pointer;
height: 3.5rem;
margin: 0.5rem;
width: 5rem;
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar.e-active .indicator {
background-color: #c1cdda;
}
.preview-content {
align-items: center;
display: flex;
height: 100%;
justify-content: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :indicatorsTemplate="indicatorsTemplate">
<e-carousel-items>
<e-carousel-item template="<div class='slide-content'>Slide 1</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 2</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 3</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 4</div>"></e-carousel-item>
<e-carousel-item template="<div class='slide-content'>Slide 5</div>"></e-carousel-item>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
import { createApp } from "vue";
var indicatorsVue = createApp().component("indicators", {
data() { return {} },
template: `<div class="indicator" indicator-index="{data.index}">
<div class="preview-content"></div>
</div>`,
computed: {},
methods: {
getContent: function (index) {
var slides = ["Slide 1", "Slide 2", "Slide 3", "Slide 4", "Slide 5"];
return slides[index];
}
}
});
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
},
data: function () {
return {
indicatorsTemplate: function () {
return {
template: indicatorsVue,
};
},
};
},
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.e-carousel {
background-color: #adb5bd;
height: 300px !important;
margin: 0 auto;
width: 500px !important;
}
.e-carousel .slide-content {
align-items: center;
display: flex;
font-size: 1.25rem;
height: 100%;
justify-content: center;
}
.e-carousel .e-carousel-items,
.e-carousel .e-carousel-navigators {
height: calc(100% - 3rem);
}
.e-carousel .e-carousel-navigators .e-previous,
.e-carousel .e-carousel-navigators .e-next,
.e-carousel .e-carousel-navigators .nav-btn {
padding: 0;
}
.e-carousel .e-carousel-navigators .nav-btn:active,
.e-carousel .e-carousel-navigators .nav-btn:focus,
.e-carousel .e-carousel-navigators .nav-btn:hover {
background-color: transparent !important;
color: inherit;
}
.e-carousel .e-carousel-navigators svg {
fill: none;
stroke: currentColor;
stroke-linecap: square;
stroke-width: 8px;
height: 2rem;
vertical-align: middle;
width: 2rem;
}
.e-carousel .e-carousel-navigators .e-previous svg {
transform: rotate(180deg);
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar .indicator {
background-color: #adb5bd;
border: 1px solid black;
border-radius: 0.25rem;
cursor: pointer;
height: 3.5rem;
margin: 0.5rem;
width: 5rem;
}
.e-carousel .e-carousel-indicators .e-indicator-bars .e-indicator-bar.e-active .indicator {
background-color: #c1cdda;
}
.preview-content {
align-items: center;
display: flex;
height: 100%;
justify-content: center;
}
</style>
Indicators Types
Choose different types of indicators available using the indicatorsType
property. The indicator types are categorized as follows:
Default Indicator
A default indicator in a carousel is a set of dots that indicate the current position of the slide in the carousel. The Default indicator can be achieved by setting the indicatorsType
to Default
.
<template>
<div class="control-container">
<ejs-carousel :indicatorType="Default">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :indicatorType="Default">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Dynamic Indicator
A dynamic indicator in a carousel provides visual cues or markers that dynamically change or update to indicate the current position. The Dynamic indicator can be achieved by setting the indicatorsType
to Dynamic
.
<template>
<div class="control-container">
<ejs-carousel :indicatorsType="Dynamic">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :indicatorsType="Dynamic">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Fraction Indicator
The fraction indicator type displays the current slide index and total slide count as a fraction. The Fraction indicator can be achieved by setting the indicatorsType
to Fraction
.
<template>
<div class="control-container">
<ejs-carousel :indicatorsType="Fraction">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :indicatorsType="Fraction">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Progress Indicator
The Progress Indicator type displays the current slide as a progress bar. The Progress indicator can be achieved by setting the indicatorsType
to Progress
.
<template>
<div class="control-container">
<ejs-carousel :indicatorsType="Progress">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :indicatorsType="Progress">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Play button
Show or hide the play button
In the carousel, autoPlay
actions have been controlled by using the showPlayButton
property in the user interface. When you enable this property, the slide transitions are controlled using this play and pause button. This property depends on the buttonsVisibility
property. The following example depicts the code to show the play button in the carousel.
<template>
<div class="control-container">
<ejs-carousel :showPlayButton="true">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel :showPlayButton="true">
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
Play button template
Template option is provided to customize the play button by using the playButtonTemplate
property. The following example depicts the code for applying a template to play Button in the carousel.
<template>
<div class="control-container">
<ejs-carousel ref="Carousel_instance" :showPlayButton="true" :playButtonTemplate="'playTemplate'">
<template v-slot:playTemplate>
<ejs-button ref="playBtn" cssClass="e-info playBtn" content="Pause" v-on:click="btnClick"></ejs-button>
</template>
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script setup>
import { CarouselComponent as EjsCarousel, CarouselItemsDirective as ECarouselItems, CarouselItemDirective as ECarouselItem } from '@syncfusion/ej2-vue-navigations';
import { ButtonComponent as EjsButton } from "@syncfusion/ej2-vue-buttons";
import { ref } from 'vue';
const playBtn = ref(null);
const Carousel_instance = ref(null);
const btnClick = () => {
if (Carousel_instance.value.ej2Instances.autoPlay) {
Carousel_instance.value.ej2Instances.autoPlay = false;
playBtn.value.ej2Instances.content = "Play";
} else {
Carousel_instance.value.ej2Instances.autoPlay = true;
playBtn.value.ej2Instances.content = "Pause";
}
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>
<template>
<div class="control-container">
<ejs-carousel ref="Carousel_instance" :showPlayButton="true" :playButtonTemplate="'playTemplate'">
<template v-slot:playTemplate>
<ejs-button ref="playBtn" cssClass="e-info playBtn" content="Pause" v-on:click="btnClick"></ejs-button>
</template>
<e-carousel-items>
<e-carousel-item template="Cardinal"></e-carousel-item>
<template v-slot:Cardinal>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/cardinal.png" alt="Cardinal"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">Cardinal</figcaption>
</figure>
</template>
<e-carousel-item template="kingfisher"></e-carousel-item>
<template v-slot:kingfisher>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/hunei.png" alt="kingfisher"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">kingfisher</figcaption>
</figure>
</template>
<e-carousel-item template="keel-billed-toucan"></e-carousel-item>
<template v-slot:keel-billed-toucan>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/costa-rica.png" alt="keel-billed-toucan"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">keel-billed-toucan</figcaption>
</figure>
</template>
<e-carousel-item template="yellow-warbler"></e-carousel-item>
<template v-slot:yellow-warbler>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/kaohsiung.png" alt="yellow-warbler"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">yellow-warbler</figcaption>
</figure>
</template>
<e-carousel-item template="bee-eater"></e-carousel-item>
<template v-slot:bee-eater>
<figure class="img-container">
<img src="https://ej2.syncfusion.com/products/images/carousel/bee-eater.png" alt="bee-eater"
style="height: 100%; width: 100%" />
<figcaption class="img-caption">bee-eater</figcaption>
</figure>
</template>
</e-carousel-items>
</ejs-carousel>
</div>
</template>
<script>
import { CarouselComponent, CarouselItemDirective, CarouselItemsDirective } from "@syncfusion/ej2-vue-navigations";
import { ButtonComponent } from "@syncfusion/ej2-vue-buttons";
export default {
name: "App",
components: {
"ejs-carousel": CarouselComponent,
"ejs-button": ButtonComponent,
"e-carousel-items": CarouselItemsDirective,
"e-carousel-item": CarouselItemDirective
},
methods: {
btnClick: function () {
if (this.$refs.Carousel_instance.ej2Instances.autoPlay) {
this.$refs.Carousel_instance.ej2Instances.autoPlay = false;
this.$refs.playBtn.ej2Instances.content = "Play";
} else {
this.$refs.Carousel_instance.ej2Instances.autoPlay = true;
this.$refs.playBtn.ej2Instances.content = "Pause";
}
},
},
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
.control-container {
height: 360px;
margin: 0 auto;
width: 600px;
}
.img-container {
height: 100%;
margin: 0;
}
.img-caption {
color: #fff;
font-size: 1rem;
position: absolute;
bottom: 3rem;
width: 100%;
text-align: center;
}
</style>