androidx.compose.material3.carousel
HorizontalMultiBrowseCarousel
Composable function
A carousel is a horizontal list of items, usually photos, that the user swipes through.
HorizontalMultiBrowseCarousel: one large item, then smaller ones that grow as they scroll in.HorizontalUncontainedCarousel: all items the same width. The last one is cut off at the edge.HorizontalCenteredHeroCarousel: one large item in the center, small ones on both sides.

val colors = listOf(Color(0xFF8E6CEF), Color(0xFFEF6C8E), Color(0xFF6CB4EF), Color(0xFF6CEF9B), Color(0xFFEFC36C))
HorizontalMultiBrowseCarousel(
state = rememberCarouselState { colors.size },
preferredItemWidth = 186.dp,
itemSpacing = 8.dp,
modifier = Modifier.width(360.dp).height(200.dp),
) { index ->
// maskClip gives each item the rounded shape that changes while scrolling.
Box(
Modifier.fillMaxSize().maskClip(MaterialTheme.shapes.extraLarge).background(colors[index]),
contentAlignment = Alignment.Center,
) { Text("Photo ${index + 1}", color = Color.White) }
}
Inside each item, use Modifier.maskClip(shape) instead of clip. It lets the carousel change the item's shape while it scrolls.

val colors = listOf(Color(0xFF8E6CEF), Color(0xFFEF6C8E), Color(0xFF6CB4EF), Color(0xFF6CEF9B))
HorizontalUncontainedCarousel(
state = rememberCarouselState { colors.size },
itemWidth = 150.dp,
itemSpacing = 8.dp,
modifier = Modifier.width(360.dp).height(160.dp),
) { index ->
Box(Modifier.fillMaxSize().maskClip(MaterialTheme.shapes.extraLarge).background(colors[index]))
}
Parameters
@Composable
fun HorizontalMultiBrowseCarousel(
state: CarouselState,
preferredItemWidth: Dp,
modifier: Modifier = Modifier,
itemSpacing: Dp = 0.dp,
flingBehavior: TargetedFlingBehavior = CarouselDefaults.singleAdvanceFlingBehavior(state = state),
userScrollEnabled: Boolean = true,
minSmallItemWidth: Dp = CarouselDefaults.MinSmallItemSize,
maxSmallItemWidth: Dp = CarouselDefaults.MaxSmallItemSize,
contentPadding: PaddingValues = PaddingValues(0.dp),
content: @Composable CarouselItemScope.(itemIndex: Int) -> Unit,
)
state: CarouselStateRequired
state: CarouselStateRequiredThe scroll position and item count. Create it with rememberCarouselState { itemCount }.
preferredItemWidth: DpRequired
preferredItemWidth: DpRequiredThe width of the large item. The carousel fits as many as it can, and fills the rest with smaller items.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. Set the height here.
itemSpacing: DpOptional
itemSpacing: DpOptionalDefault: 0.dp
The gap between items.
flingBehavior: TargetedFlingBehaviorOptional
flingBehavior: TargetedFlingBehaviorOptionalDefault: CarouselDefaults.singleAdvanceFlingBehavior(state = state)
How the carousel moves after a swipe: one item at a time, or freely.
userScrollEnabled: BooleanOptionalSince 1.9
userScrollEnabled: BooleanOptionalSince 1.9Default: true
Set to false to stop the user from scrolling.
minSmallItemWidth: DpOptional
minSmallItemWidth: DpOptionalDefault: CarouselDefaults.MinSmallItemSize
The narrowest a small item can be.
maxSmallItemWidth: DpOptional
maxSmallItemWidth: DpOptionalDefault: CarouselDefaults.MaxSmallItemSize
The widest a small item can be.
contentPadding: PaddingValuesOptional
contentPadding: PaddingValuesOptionalDefault: PaddingValues(0.dp)
Space before the first and after the last item.
content: @Composable CarouselItemScope.(itemIndex: Int) -> UnitRequired
content: @Composable CarouselItemScope.(itemIndex: Int) -> UnitRequiredDraws one item. Receives the item index.
Carousel types
HorizontalMultiBrowseCarouselHorizontalUncontainedCarouselHorizontalCenteredHeroCarousel