-
Notifications
You must be signed in to change notification settings - Fork 7
Carousel
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.
Returns the number of slides currently loaded into the carousel.
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.
The following components are typically used with a Carousel
component.
Below are a few examples of how to use the Carousel
component.
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.
<Carousel
AutoStart="false"
ShowControls="true"
ShowIndicators="true"
ImageUrls='@(new[] { "...", "...", "..." })'
/>
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">
<CarouselItem
CaptionHeading="The Image"
CaptionBody="This is the body text of the caption"
ImageUrl="..."
/>
<CarouselItem
CaptionHeading="Another Image"
CaptionBody="Here's the second image in the slide deck"
ImageUrl="..."
/>
</Carousel>
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
}
}
<Carousel
OnSlide="(e) => { DoStuff(e); }"
OnSlid="async (e) => { await DoStuffAsync(e); }"
/>
The sample below shows you how you can add just about any content to your carousel. This sample uses the Jumbotron
and Card
components.
<Carousel>
<CarouselItem>
<Jumbotron
Heading="Custom Carousel Slide"
Lead="How to use a Jumbotron component as a slide in a Carousel component."
/>
</CarouselItem>
<CarouselItem>
<Card
Header="Card Slide Item"
Title="Card in a Carousel"
Text="Here we have a card inside of a Carousel component."
/>
</CarouselItem>
</Carousel>
- Home
- Design Principles
- Getting Started
- Components
- Content
- Layout Components
- Generic Elements
- Utilities
- Releases