Skip to content


Mika Berglund edited this page Feb 28, 2020 · 7 revisions

Carousel Component

A slideshow component for cycling through elements with virtually any kind of content.


Carousel : BootstrapComponentBase


Name Type Description
AutoStart bool Specifies whether the carousel should start automatically when loaded.
ImageUrls string[] An array of URLs pointing to images to show in the carousel.
Interval int The number of milliseconds each slide should be shown. The default is 5000ms.
ShowControls bool Specifies whether to show to controls on the carousel that allows the user to navigate to the next or previous slide.
ShowIndicators bool Specifies whether to show an indicator for each slide.
TransitionType CarouselTransitionType Specifies how to transition from one slide to the other. The default is CarouselTransitionType.Slide.


Name Type Description
SlideCount int Returns the number of slides currenty loaded into the carousel.


Name Argument Type Description
OnSlide CarouselSlideEventArgs Fired when the transition from one slide to another has started, but before it is completed.
OnSlid CarouselSlideEventArgs Fired when the transition from one slide to another has completed.



Starts cycling through the slides in the carousel.

Task<int?> GetSlideCountAsync()

Returns the number of slides currently loaded into the carousel.

GoToSlideAsync(int slideNumber)

Moves the carousel to the given slide.

  • slideNumber - The zero-based index of the slide to move to.


Pauses the cycling of slides. The cycling can still be controlled with the other methods. Start auto cycling again with the CycleAsync() method.


Moves the carousel to the next slide. If the carousel is on the last slide, it will move to the first.


Moves the carousel to the previous slide. If the carousel is on the first slide, it will move to the last.

Related Components

The following components are typically used with a Carousel component.


Below are a few examples of how to use the Carousel component.

Images Only

If you only want to show a deck of images, you can use the ImageUrls property. The sample below will also prevent the carousel from starting automatically, and it will show the controls and indicators on the images.

    ImageUrls='@(new[] { "...", "...", "..." })'

Adding Captions to Images

In addition to only images, you can specify captions that are shown over your images. This sample also uses the CarouselItem component.

<Carousel Interval="2000">
        CaptionHeading="The Image"
        CaptionBody="This is the body text of the caption"
        CaptionHeading="Another Image"
        CaptionBody="Here's the second image in the slide deck"

Responding to Events

This code demonstrates how you can respond to the events that the Carousel component exposes. The two event hanlders below just show you how you can do a synchronous or asynchronous event handler. Choose which suits you best.

@code {
    public void DoStuff(CarouselSlideEventArgs e)
        // Do stuff here

    public async Task DoStuffAsync(CarouselSlideEventArgs e)
        // Do stuff here

    OnSlide="(e) => { DoStuff(e); }"
    OnSlid="async (e) => { await DoStuffAsync(e); }"

Custom Content

The sample below shows you how you can add just about any content to your carousel. This sample uses the Jumbotron and Card components.

            Heading="Custom Carousel Slide"
            Lead="How to use a Jumbotron component as a slide in a Carousel component."
            Header="Card Slide Item"
            Title="Card in a Carousel"
            Text="Here we have a card inside of a Carousel component."
You can’t perform that action at this time.