Build apps faster with our new App builder! Check it out →

pullToRefresh

Common

Modifier in Material 3 Compose

A Modifier that adds nested scroll to a container to support a pull-to-refresh gesture. When the user pulls a distance greater than [threshold] and releases the gesture, [onRefresh] is invoked. [PullToRefreshBox] applies this automatically.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.material3:material3:1.4.0-alpha02")
}

Overloads

@ExperimentalMaterial3Api
fun Modifier.pullToRefresh(
    isRefreshing: Boolean,
    state: PullToRefreshState,
    enabled: Boolean = true,
    threshold: Dp = PullToRefreshDefaults.PositionalThreshold,
    onRefresh: () -> Unit,
): Modifier

Parameters

namedescription
isRefreshingwhether a refresh is occurring or not, if there is no gesture in progress when isRefreshing is false the state.distanceFraction will animate to 0f, otherwise it will animate to 1f
statestate that keeps track of the distance pulled
enabledwhether nested scroll events should be consumed by this modifier
thresholdhow much distance can be scrolled down before [onRefresh] is invoked
onRefreshcallback that is invoked when the distance pulled is greater than [threshold]
by @alexstyl