Bootstrap Vue Carousel Component
Bootstrap Vue carousel is a slideshow component for cycling through elements—images or slides of text—like a carousel.
How it works
The Vue carousel is a slideshow for cycling within a group of content. It runs with a group of images, text, or html elements. It also incorporates support for previous/next buttons.
In browsers where the Page Visibility APIopen in new window is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).
Example
Carousels don't automatically normalize slide dimensions. As such, you may want to use extra utilities or custom methods to properly size content. While carousels support previous/next controls and indicators, they're not explicitly expected. Add and customize as you see fit.
Slides only
<CCarousel>
<CCarouselItem>
<img class="d-block w-100" src="/images/vue.jpg" alt="slide 1"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/react.jpg" alt="slide 2"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/angular.jpg" alt="slide 3"/>
</CCarouselItem>
</CCarousel>
2
3
4
5
6
7
8
9
10
11
With controls
Adding in the previous and next controls by controls
property.
<CCarousel controls>
<CCarouselItem>
<img class="d-block w-100" src="/images/vue.jpg" alt="slide 1"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/react.jpg" alt="slide 2"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/angular.jpg" alt="slide 3"/>
</CCarouselItem>
</CCarousel>
2
3
4
5
6
7
8
9
10
11
With indicators
You can attach the indicators to the carousel, lengthwise the controls, too.
<CCarousel controls>
<CCarouselItem>
<img class="d-block w-100" src="/images/vue.jpg" alt="slide 1"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/react.jpg" alt="slide 2"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/angular.jpg" alt="slide 3"/>
</CCarouselItem>
</CCarousel>
2
3
4
5
6
7
8
9
10
11
With captions
You can add captions to slides with the <CCarouselCaption>
element within any <CCarouselItem>
. They can be immediately hidden on smaller viewports, as shown below, with optional display utilitiesopen in new window. We hide them with .d-none
and draw them back on medium-sized devices with .d-md-block
.
<CCarousel controls indicators>
<CCarouselItem>
<img class="d-block w-100" src="/images/vue.jpg" alt="slide 1"/>
<CCarouselCaption class="d-none d-md-block">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</CCarouselCaption>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/react.jpg" alt="slide 2"/>
<CCarouselCaption class="d-none d-md-block">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</CCarouselCaption>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/angular.jpg" alt="slide 3"/>
<CCarouselCaption class="d-none d-md-block">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</CCarouselCaption>
</CCarouselItem>
</CCarousel>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Crossfade
Add transition="crossfade"
to your carousel to animate slides with a fade transition instead of a slide.
<CCarousel controls indicators transition="crossfade">
<CCarouselItem>
<img class="d-block w-100" src="/images/vue.jpg" alt="slide 1"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/react.jpg" alt="slide 2"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/angular.jpg" alt="slide 3"/>
</CCarouselItem>
</CCarousel>
2
3
4
5
6
7
8
9
10
11
Dark variant
Add dark
property to the CCarousel
for darker controls, indicators, and captions. Controls have been inverted from their default white fill with the filter
CSS property. Captions and controls have additional Sass variables that customize the color
and background-color
.
<CCarousel controls indicators transition="crossfade">
<CCarouselItem>
<img class="d-block w-100" src="/images/vue.jpg" alt="slide 1"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/react.jpg" alt="slide 2"/>
</CCarouselItem>
<CCarouselItem>
<img class="d-block w-100" src="/images/angular.jpg" alt="slide 3"/>
</CCarouselItem>
</CCarousel>
2
3
4
5
6
7
8
9
10
11
API
CCarousel
import { CCarousel } from '@coreui/bootstrap-vue'
// or
import CCarousel from '@coreui/bootstrap-vue/src/components/carousel/CCarousel'
2
3
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
controls | Adding in the previous and next controls. | boolean | - | |
dark | Add darker controls, indicators, and captions. | boolean | - | |
index | index of the active item. | number | - | 0 |
indicators | Adding indicators at the bottom of the carousel for each item. | boolean | - | |
interval | The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. | boolean|number | - | 5000 |
pause | If set to 'hover', pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to false, hovering over the carousel won't pause it. | boolean|string | - | 'hover' |
transition | Set type of the transition. | string | 'crossfade' , 'slide' | 'slide' |
wrap | Set whether the carousel should cycle continuously or have hard stops. | boolean | - | true |
CCarouselItem
import { CCarouselItem } from '@coreui/bootstrap-vue'
// or
import CCarouselItem from '@coreui/bootstrap-vue/src/components/carousel/CCarouselItem'
2
3
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
interval | The amount of time to delay between automatically cycling an item. | boolean|number | - | false |