PullToRefresh

fun PullToRefresh(isRefreshing: Boolean, onRefresh: () -> Unit, modifier: Modifier = Modifier, pullToRefreshState: PullToRefreshState = rememberPullToRefreshState(), contentPadding: PaddingValues = PaddingValues(0.dp), topAppBarScrollBehavior: ScrollBehavior? = null, color: Color = PullToRefreshDefaults.color, circleSize: Dp = PullToRefreshDefaults.circleSize, refreshTexts: List<String> = PullToRefreshDefaults.refreshTexts, refreshTextStyle: TextStyle = PullToRefreshDefaults.refreshTextStyle, content: @Composable () -> Unit)

A container that supports the "pull-to-refresh" gesture.

This composable follows a hoisted state pattern, where the logical isRefreshing state is managed by the caller (e.g., a ViewModel). It coordinates nested scrolling to enable a pull-to-refresh action, displays a customizable indicator, and triggers a callback when a refresh is requested.

Parameters

isRefreshing

A boolean state representing whether a refresh is currently in progress. This state should be hoisted and is the source of truth for the refresh operation.

onRefresh

A lambda to be invoked when a refresh is triggered by the user. This lambda should initiate the data loading and is responsible for eventually setting isRefreshing back to false upon completion.

modifier

The modifier to be applied to this container.

pullToRefreshState

The state object that manages the UI and animations of the indicator. See rememberPullToRefreshState.

contentPadding

The padding to be applied to the content. The top padding is used to correctly offset the refresh indicator.

topAppBarScrollBehavior

An optional ScrollBehavior for a TopAppBar to coordinate scrolling between the app bar and the pull-to-refresh gesture.

color

The color of the refresh indicator.

circleSize

The size of the refresh indicator's animated circle.

refreshTexts

A list of strings representing the text shown in different states.

refreshTextStyle

The TextStyle for the refresh indicator text.

content

The content to be displayed inside the container.