← Back to Tv Material
Carousel
Component
in
Tv Material
. Since 1.0.0-alpha07Overview
Code Examples
Video
Composes a hero card rotator to highlight a piece of content.
Examples:
Overloads
Carousel
@Suppress("IllegalExperimentalApiUsage")
@OptIn(ExperimentalComposeUiApi::class)
@ExperimentalTvMaterial3Api
@Composable
fun Carousel(
itemCount: Int,
modifier: Modifier = Modifier,
carouselState: CarouselState = remember { CarouselState() },
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 CarouselScope.(index: Int) -> Unit
)
Parameters
Name | Description |
---|---|
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 |