Carousel

Composable Component

Composes a hero card rotator to highlight a piece of content.

Android
@ExperimentalTvMaterial3Api
@Composable
fun Carousel(
    itemCount: Int,
    modifier: Modifier = Modifier,
    carouselState: CarouselState = rememberCarouselState(),
    autoScrollDurationMillis: Long = CarouselDefaults.TimeToDisplayItemMillis,
    contentTransformStartToEnd: ContentTransform = CarouselDefaults.contentTransform,
    contentTransformEndToStart: ContentTransform = CarouselDefaults.contentTransform,
    carouselIndicator: @Composable BoxScope.() -> Unit = {
        CarouselDefaults.IndicatorRow(
            itemCount = itemCount,
            activeItemIndex = carouselState.activeItemIndex,
            modifier = Modifier.align(Alignment.BottomEnd).padding(16.dp),
        )
    },
    content: @Composable AnimatedContentScope.(index: Int) -> Unit
)

Parameters

modifierModifier applied to the Carousel.
itemCounttotal number of items present in the carousel.
carouselStatestate associated with this carousel.
autoScrollDurationMillisduration for which item should be visible before moving to the next item.
contentTransformStartToEndanimation transform applied when we are moving from start to end in the carousel while scrolling to the next item
contentTransformEndToStartanimation transform applied when we are moving from end to start in the carousel while scrolling to the next item
carouselIndicatorindicator showing the position of the current item among all items.
contentdefines the items for a given index.