Can I show multiple slides at once using Blazor carousel?

Hi,

Is there a way to show multiple slides at once using the Blazor carousel component?

I have a requirement that is similar to the image below. Thanks.

carousel-example.png


5 Replies

RM Ruksar Moosa Sait Syncfusion Team July 15, 2022 10:08 AM UTC

Hi David,


Greetings from Syncfusion support.


Yes. You can create multiple slides at once in the Carousel component by looping the list of carousel items from the carousel data source as shown in the below code.


[Index.html]

<SfCarousel AnimationEffect="CarouselAnimationEffect.Fade">

    @foreach (CarouselData data in CarouselDatas)

       {

          <CarouselItem>

              <div style="display:flex;height:100%">

                  @foreach (CarouselItemModel item in data.Items)

                  {

                      <figure class="img-container">

                          <img src=Images/@item.ImageName style="height:100%;width:100%;" />

                          <figcaption class="img-caption">@item.Text</figcaption>

                       </figure>

                   }

               </div>

          </CarouselItem>

       }

</SfCarousel>


List<CarouselData> CarouselDatas = new List<CarouselData>

    {

       new CarouselData

       { Items = new List<CarouselItemModel>

          {

             new CarouselItemModel(){Text = "Image 1" , ImageName="bee-eater.png" },

             new CarouselItemModel(){Text = "Image 2" , ImageName="cardinal.png" },

             new CarouselItemModel(){Text = "Image 3" , ImageName="costa-rica.png" }

           }

    },

    new CarouselData

       { Items = new List<CarouselItemModel>

          {

             new CarouselItemModel(){Text = "Image 4" , ImageName="hunei.png" },

             new CarouselItemModel(){Text = "Image 5" , ImageName="kaohsiung.png" },

             new CarouselItemModel(){Text = "Image 6" , ImageName="bee-eater.png" }

           }

    },

    new CarouselData

       { Items = new List<CarouselItemModel>

          {

             new CarouselItemModel(){Text = "Image 7" , ImageName="cardinal.png" },

             new CarouselItemModel(){Text = "Image 8" , ImageName="costa-rica.png" },

             new CarouselItemModel(){Text = "Image 9" , ImageName="hunei.png" }

           }

        }

    };


Output:

A couple of birds on a branch

Description automatically generated with low confidence


Kindly try the attached sample and let us know if this meets your requirement.


Regards,

Ruksar Moosa Sait


Attachment: CarouselMultipleSlides_7e05fdd3.zip


DE David Evans July 15, 2022 11:29 AM UTC

That's what I need. Cool, thanks. 



SK Satheesh Kumar Balasubramanian Syncfusion Team July 18, 2022 05:54 AM UTC

Hi David,


Thanks for the update.

We are happy that your problem has been resolved now.


Regards,

Satheesh Kumar B



MA Marco Antonio January 15, 2024 03:29 PM UTC

This solution in my opinion is not complete, due the fact that the carousel scroll each page. what if i want a carousel thet scroll signle item but show for instance 3 item, maybe focusing at the central item ?



AK Ashokkumar Karuppasamy Syncfusion Team January 16, 2024 02:02 PM UTC

Hi David,

You can achieve your requirement by using the Carousel
PartialVisible property. The following sample and documentation illustrates the solution. Please give it a try, and let us know if you need any further assistance.

Sample:
https://blazor.syncfusion.com/demos/carousel/partial-visible?theme=fluent

UG:
https://blazor.syncfusion.com/documentation/carousel/populating-items#partial-visible-slides

Regards,
Ashok


Loader.
Up arrow icon