StylishCarousel

fun StylishCarousel(itemCount: () -> Int, preferredItemWidth: Dp, state: CarouselState = rememberCarouselState(itemCount = itemCount), 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.(index: Int) -> Unit)

A horizontally scrolling carousel that centers a focal item and shows smaller sibling items on both sides (multi-browse layout).

This is the Finish-layer wrapper around the Material 3 HorizontalMultiBrowseCarousel under the ExperimentalMaterial3Api opt-in, so callers can use the carousel without importing the experimental androidx.compose.material3.carousel API. The wrapper remembers its own CarouselState from itemCount and forwards all sizing parameters unchanged; the default fling behavior advances at most one item per fling (CarouselDefaults.singleAdvanceFlingBehavior). Item appearance is fully owned by the caller through content; for the Stylish look, clip each item with CarouselItemScope.maskClip using RoundedCornerShape with StylishTheme.dimensions.connectedCornerRadius.

Parameters

itemCount

A lambda returning the number of carousel items. Used to construct the default state via rememberCarouselState; ignored when a custom state is supplied.

preferredItemWidth

The preferred width of the focal item, in dp.

state

The CarouselState controlling scroll position and the current item. Defaults to rememberCarouselState with itemCount.

modifier

Modifier applied to the carousel root.

itemSpacing

The gap between adjacent items. Defaults to 0 dp (matching the M3 default).

flingBehavior

The fling behavior after a swipe gesture. Defaults to CarouselDefaults.singleAdvanceFlingBehavior, which snaps to the next item.

userScrollEnabled

Whether the user can scroll the carousel. Defaults to true.

minSmallItemWidth

The minimum width a small (non-focal) item may shrink to. Defaults to CarouselDefaults.MinSmallItemSize (40 dp).

maxSmallItemWidth

The maximum width a small (non-focal) item may grow to. Defaults to CarouselDefaults.MaxSmallItemSize (56 dp).

contentPadding

Padding around the whole content, applied after clipping. Defaults to no padding.

content

A composable that renders the carousel item at the given index. Receives CarouselItemScope for size-aware helpers such as CarouselItemScope.maskClip.

See also