Carousel
Interactive slideshow for cycling through a series of content.
Slide 1
This is the first slide
Slide 2
This is the second slide
Slide 3
This is the third slide
package showcase
import "github.com/templui/templui/components/carousel"
import "github.com/templui/templui/components/card"
templ CarouselDefault() {
@carousel.Carousel(carousel.Props{
Class: "rounded-md",
}) {
@carousel.Content() {
@carousel.Item() {
@CarouselSlide("Slide 1", "This is the first slide")
}
@carousel.Item() {
@CarouselSlide("Slide 2", "This is the second slide")
}
@carousel.Item() {
@CarouselSlide("Slide 3", "This is the third slide")
}
}
@carousel.Previous()
@carousel.Next()
@carousel.Indicators(carousel.IndicatorsProps{
Count: 3,
})
}
}
templ CarouselSlide(title, description string) {
@card.Card() {
@card.Content() {
<div class={ "w-full h-96 flex items-center justify-center" }>
<div class="text-center">
<h2 class="text-3xl font-bold mb-2">{ title }</h2>
<p class="text-xl">{ description }</p>
</div>
</div>
}
}
}
Installation
templui add carouselLoad the script once in your layout:
<head>
@carousel.Script()
</head>import "github.com/templui/templui/components/carousel"Load the script once in your layout:
<head>
@carousel.Script()
</head>API Reference
Carousel
Main carousel container component for interactive slideshows.
| Name | Type | Default |
|---|---|---|
Unique identifier for the carousel element. | | - |
Additional CSS classes to apply to the carousel. | | - |
Additional HTML attributes to apply to the carousel element. | | - |
Whether the carousel should automatically advance slides. | | |
Time in milliseconds between automatic slide transitions. | | |
Whether the carousel should loop back to the first slide after the last. | | |
Content
Container for carousel slides with smooth transitions.
| Name | Type | Default |
|---|---|---|
Unique identifier for the content element. | | - |
Additional CSS classes to apply to the content. | | - |
Additional HTML attributes to apply to the content element. | | - |
Item
Individual carousel slide container.
| Name | Type | Default |
|---|---|---|
Unique identifier for the item element. | | - |
Additional CSS classes to apply to the item. | | - |
Additional HTML attributes to apply to the item element. | | - |
Previous
Navigation button to go to the previous slide.
| Name | Type | Default |
|---|---|---|
Unique identifier for the previous button element. | | - |
Additional CSS classes to apply to the previous button. | | - |
Additional HTML attributes to apply to the previous button element. | | - |
Next
Navigation button to go to the next slide.
| Name | Type | Default |
|---|---|---|
Unique identifier for the next button element. | | - |
Additional CSS classes to apply to the next button. | | - |
Additional HTML attributes to apply to the next button element. | | - |
Indicators
Dot indicators showing current slide position and allowing direct navigation.
| Name | Type | Default |
|---|---|---|
Unique identifier for the indicators element. | | - |
Additional CSS classes to apply to the indicators. | | - |
Additional HTML attributes to apply to the indicators element. | | - |
Number of indicator dots to display (should match number of slides). | | - |