Carousel
An image carousel.
1 2 3 4 5
use leptos::prelude::*; use singlestage::{card::*, carousel::*}; #[component] pub fn CarouselExample() -> impl IntoView { let carousel_items = RwSignal::new((1..6).collect::<Vec<usize>>()); view! { <Carousel class="w-full max-w-xs"> <CarouselContent> <For each=move || carousel_items.get() key=|item| *item let(item)> <CarouselItem> <Card> <CardContent class="flex aspect-square items-center justify-center"> <span class="text-4xl font-semibold">{item.to_string()}</span> </CardContent> </Card> </CarouselItem> </For> </CarouselContent> <CarouselPrevious /> <CarouselNext /> </Carousel> } }
Anatomy
Import all parts and piece them together.
use leptos::prelude::*; use singlestage::carousel::*; #[component] pub fn CarouselAnatomy() -> impl IntoView { view! { <Carousel> <CarouselContent> <CarouselItem /> <CarouselPrevious /> <CarouselNext /> </CarouselContent> </Carousel> } }
API Reference
CarouselItem
Contains a single piece of content for the carousel.
CarouselNext
A button that triggers the change to the next available carousel item.
| Name | Type | Default | Description |
|---|---|---|---|
| button_type | String | "button" | Renamed <button> `type` attribute to avoid name collisions. |