apps/www/content/docs/components/carousel.mdx
import { Carousel } from "@chakra-ui/react"
<Carousel.Root>
<Carousel.ItemGroup>
<Carousel.Item />
</Carousel.ItemGroup>
<Carousel.Control>
<Carousel.AutoplayTrigger>
<Carousel.AutoplayIndicator />
</Carousel.AutoplayTrigger>
<Carousel.PrevTrigger />
<Carousel.Indicators />
<Carousel.NextTrigger />
<Carousel.ProgressText />
</Carousel.Control>
</Carousel.Root>
The Carousel component also provides convenient shortcuts for common patterns.
The Carousel.Indicators shortcut renders a full set of indicators
automatically based on the number of slides.
<Carousel.IndicatorGroup>
{Array.from({ length: items.length }, (_, index) => (
<Carousel.Indicator key={index} index={index} />
))}
</Carousel.IndicatorGroup>
This might be more concise if you don't need to customize each indicator:
<Carousel.Indicators />
Use the page and onPageChange props to programatically control the active
carousel page.
Alternatively, use the useCarousel hook to create a carousel store and pass it
to the Carousel.RootProvider component for full programmatic control.
Use the Carousel.PrevTrigger and Carousel.NextTrigger components to create
arrows that navigate between slides.
Use the Carousel.Indicators component to render visual indicators that help
users track the progress of the carousel and jump to specific slides.
Here's an example that uses an image thumbnail as a custom indicator.
<ExampleTabs name="carousel-with-thumbnails" />Use the spacing prop to control the spacing between slides.
Use the autoSize prop to allow variable width/height slide items.
Use the orientation prop to vertical to transform your carousel into a
vertical slider.
Use the allowMouseDrag prop to enable mouse dragging on the carousel.
Pass the autoplay prop to the Carousel.Root component to make the carousel
automatically move between slides.
Compose the Carousel component with the Dialog component to create a
lightbox.
Here's an example that shows how to create an image carousel for a product showcase.
<ExampleTabs name="carousel-with-images" />Here's an example that shows how to compose the Carousel component with other
components to create a property card carousel.
Explore the Carousel component parts interactively. Click on parts in the
sidebar to highlight them in the preview.