Skip to content

Extra

PullToRefresh

A FormaUI pull-to-refresh container — wraps a scrollable layout and adds a swipe-down-to-refresh gesture, delegating to Material 3's stable PullToRefreshBox with fully hoisted isRefreshing state and a styling-passthrough indicator slot.

dev.formaui.components.pulltorefresh

IdleRefreshingCustom indicator

Preview

This toggle is site chrome only — the preview has its own light/dark switch inside.

Live preview

Live preview — ~37 MB development build

Usage

var refreshing by remember { mutableStateOf(false) }
val scope = rememberCoroutineScope()
FormaPullToRefresh(
    isRefreshing = refreshing,
    onRefresh = {
        refreshing = true
        scope.launch { delay(1500); refreshing = false }
    },
) {
    LazyColumn(Modifier.fillMaxSize()) {
        items(items) { item -> FormaListItem(headline = item) }
    }
}

FormaPullToRefresh

Wraps a scrollable BoxScope content with a pull-down-to-refresh gesture; the caller hoists isRefreshing and reacts in onRefresh. The indicator slot defaults to Material 3's themed PullToRefreshDefaults.Indicator aligned to the top-center (the styling passthrough).

isRefreshingrequiredTypeBooleanDefaultrequiredDescriptionwhether a refresh is currently occurring; drives the indicator's spinning state. Flip it to true when your refresh starts and back to false when it completes.
onRefreshrequiredType() -> UnitDefaultrequiredDescriptioncalled when the user's pull crosses the threshold, requesting a refresh.
modifierTypeModifierDefaultModifierDescriptionthe Modifier applied to the container.
stateTypePullToRefreshStateDefaultrememberPullToRefreshState()Descriptionthe Material 3 PullToRefreshState tracking pull distance (defaults to a rememberPullToRefreshState()).
contentAlignmentTypeAlignmentDefaultAlignment.TopStartDescriptionthe Alignment of children inside the container (defaults to Alignment.TopStart).
indicatorType@Composable BoxScope.() -> UnitDefaultPullToRefreshDefaults.Indicator(...)Descriptionthe indicator drawn on top of the content while pulling or refreshing (defaults to Material 3's PullToRefreshDefaults.Indicator aligned top-center, themed by FormaTheme). This is the styling passthrough; supply a custom indicator (e.g. PullToRefreshDefaults.LoadingIndicator) to override.
contentrequiredType@Composable BoxScope.() -> UnitDefaultrequiredDescriptionthe scrollable content of the container, laid out in a BoxScope (typically a LazyColumn or a Column with Modifier.verticalScroll).

Supporting API

rememberPullToRefreshStatefunction (Material 3)
The component defines no state type of its own — callers may create and own the pull state via Material 3's rememberPullToRefreshState; when omitted, FormaPullToRefresh remembers one internally.

Accessibility

Inherits Material 3's PullToRefreshBox gesture and indicator behavior; drive isRefreshing from your data-load state so the spinning indicator reflects the actual busy state.