PullToRefreshBox

@Composable
fun PullToRefreshBox(isRefreshing: Boolean, onRefresh: () -> Unit, modifier: Modifier = Modifier, state: PullToRefreshState = rememberPullToRefreshState(), contentAlignment: Alignment = Alignment.TopStart, indicator: @Composable BoxScope.() -> Unit = { Indicator( modifier = Modifier.align(Alignment.TopCenter), isRefreshing = isRefreshing, state = state ) }, content: @Composable BoxScope.() -> Unit)

PullToRefreshBox is a container that expects a scrollable layout as content and adds gesture support for manually refreshing when the user swipes downward at the beginning of the content. By default, it uses PullToRefreshDefaults.Indicator as the refresh indicator.

Parameters

isRefreshing

whether a refresh is occurring

onRefresh

callback invoked when the user gesture crosses the threshold, thereby requesting a refresh.

modifier

the Modifier to be applied to this container

state

the state that keeps track of distance pulled

contentAlignment

The default alignment inside the Box.

indicator

the indicator that will be drawn on top of the content when the user begins a pull or a refresh is occurring

content

the content of the pull refresh container, typically a scrollable layout such as LazyColumn or a layout using Modifier.verticalScroll

Samples

androidx.compose.material3.samples.PullToRefreshSampleandroidx.compose.material3.samples.PullToRefreshViewModelSampleandroidx.compose.material3.samples.PullToRefreshSampleCustomStateandroidx.compose.material3.samples.PullToRefreshScalingSample