androidx.compose.material3.pulltorefresh
PullToRefreshBox
Composable function
Pull to refresh lets the user reload a list by pulling it down from the top. An indicator shows while it loads.
Wrap a scrollable list in a PullToRefreshBox. Keep a Boolean for "loading" yourself:
- In
onRefresh, set it totrueand start loading. - When loading is done, set it back to
false.

PullToRefreshBox(
isRefreshing = true, // normally your state, true while loading
onRefresh = { /* start loading */ },
modifier = Modifier.size(360.dp, 260.dp),
) {
LazyColumn(Modifier.fillMaxSize()) {
items(5) { i -> ListItem(headlineContent = { Text("Message ${i + 1}") }) }
}
}
Parameters
@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) },
enabled: Boolean = true,
threshold: Dp = PullToRefreshDefaults.PositionalThreshold,
content: @Composable BoxScope.() -> Unit,
)
isRefreshing: BooleanRequired
isRefreshing: BooleanRequiredWhether content is loading. The indicator shows while this is true. Pass your state here.
onRefresh: () -> UnitRequired
onRefresh: () -> UnitRequiredCalled when the user pulls far enough and lets go. Start loading here.
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
state: PullToRefreshStateOptional
state: PullToRefreshStateOptionalDefault: rememberPullToRefreshState()
The pull distance. Create it with rememberPullToRefreshState(). Needed only for a custom indicator.
contentAlignment: AlignmentOptional
contentAlignment: AlignmentOptionalDefault: Alignment.TopStart
How the content lines up inside the box.
indicator: @Composable BoxScope.() -> UnitOptional
indicator: @Composable BoxScope.() -> UnitOptionalDefault: { Indicator(modifier = Modifier.align(Alignment.TopCenter), isRefreshing = isRefreshing, state = state) }
The spinner shown while pulling and loading. Default: PullToRefreshDefaults.Indicator.
For an Expressive look, use PullToRefreshDefaults.LoadingIndicator.
enabled: BooleanOptionalSince 1.11
enabled: BooleanOptionalSince 1.11Default: true
Set to false to turn off pulling.
threshold: DpOptionalSince 1.11
threshold: DpOptionalSince 1.11Default: PullToRefreshDefaults.PositionalThreshold
How far the user must pull before letting go starts a refresh.
content: @Composable BoxScope.() -> UnitRequired
content: @Composable BoxScope.() -> UnitRequiredThe list. It must be scrollable, like a LazyColumn.
Longer Example
Pull down to load new messages. While loading, isRefreshing is true and the indicator spins.
onRefreshstarts the loading in a coroutine and setsrefreshingback tofalsewhen it is done.- The new message is added at the top;
Modifier.animateItem()moves the others down smoothly. - The
LazyColumnfills the box. A list shorter than the box still has to be the full height, or the pull gesture can't start.

val messages = remember { mutableStateListOf("Lunch on Friday?", "Your order has shipped", "Meeting notes") }
var refreshing by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
PullToRefreshBox(
isRefreshing = refreshing,
onRefresh = {
scope.launch {
refreshing = true
delay(1500) // in an app: load from the network
messages.add(0, "New message ${messages.size + 1}")
refreshing = false
}
},
modifier = Modifier.size(360.dp, 260.dp),
) {
// The list must fill the box and be scrollable, even when it is short,
// or the pull gesture can't start.
LazyColumn(Modifier.fillMaxSize()) {
items(messages, key = { it }) { message ->
ListItem(headlineContent = { Text(message) }, modifier = Modifier.animateItem())
}
}
}