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

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
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

modifier Modifier applied to the Carousel.
itemCount total number of items present in the carousel.
carouselState state associated with this carousel.
autoScrollDurationMillis duration for which item should be visible before moving to the next item.
contentTransformStartToEnd animation transform applied when we are moving from start to end in the carousel while scrolling to the next item
contentTransformEndToStart animation transform applied when we are moving from end to start in the carousel while scrolling to the next item
carouselIndicator indicator showing the position of the current item among all items.
content defines the items for a given index.