suiss/ui ยท Interaction
Pull to Refresh
A scroll container that refreshes its content when the user pulls down from the top.
Pull to Refresh is an open-source interaction from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
PullToRefresh is a vertically scrolling container. When it is scrolled to the top, dragging down with touch, or scrolling up with a trackpad or wheel, pulls the content down with increasing resistance. An indicator above the content fills in spoke by spoke as the pull nears the threshold. Releasing past the threshold calls onRefresh, holds the content open, and swaps the indicator for the suiss/ui Spinner until the refresh finishes; a shorter pull springs back without refreshing.
The spinner stays visible for at least 600 ms so fast refreshes still read clearly. Use it for lists of fetched content, such as feeds and inboxes.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Examples
Empty list
An empty inbox refreshes from a trackpad pull and fills in with the first message.
Accessibility
- The container sets
aria-busywhile refreshing. - The spinner is labelled
Refreshing; the pull indicator isaria-hidden. - Pulling requires touch or a scroll gesture, so offer another way to refresh where it matters, such as a button.
API Reference
PullToRefresh
The scroll container that tracks the pull and shows the refresh indicator.
| Prop | Type | Default |
|---|---|---|
onRefresh | () => Promise<unknown> | unknown | Required |
Also accepts the props of React.ComponentProps<"div">.
Give PullToRefresh a bounded height so its content scrolls inside it. onRefresh is called when the user releases past the threshold and can return a promise; the container stays in the refreshing state until it settles, whether it resolves or rejects. Pulls only start at the top of the scroll position and are ignored while a refresh is in progress.
The root sets data-slot="pull-to-refresh" and data-phase (idle, pulling, refreshing, settling). The --pull and --pull-progress custom properties track the pull distance and progress toward the threshold. Transitions are disabled under prefers-reduced-motion.
Web preview
PullToRefresh is a ScrollView with a native RefreshControl. Pulling down past the top starts a refresh: a light impact haptic plays, the spinner shows, and onRefresh runs.
The spinner stays for at least 600 ms, even when onRefresh resolves sooner, so it does not flicker. It also hides if onRefresh throws or rejects. Use PullToRefreshControl to add the same behavior to a FlatList or SectionList.
Installation
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/interactions/pull-to-refresh.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/interactions/pull-to-refresh.tsx:
- Update the import paths to match your project setup.
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/interactions/pull-to-refresh.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
With flat list
Uses PullToRefreshControl as the refreshControl of a FlatList.

Accessibility
PullToRefreshexposes abusystate while refreshing.PullToRefreshControlis labelledRefreshingwhile active.
API Reference
PullToRefreshControl
A RefreshControl for any list or scroll view.
| Prop | Type | Default |
|---|---|---|
onRefresh | RefreshHandler | Required |
refreshing | boolean | - |
Also accepts the props of RefreshControlProps.
For lists, pass <PullToRefreshControl onRefresh={...} /> as the list's refreshControl. It manages its own refreshing state; pass refreshing to override it. The spinner waits for the promise onRefresh returns.
PullToRefresh
A ScrollView with built-in pull to refresh.
| Prop | Type | Default |
|---|---|---|
onRefresh | RefreshHandler | Required |
Also accepts the props of React.ComponentProps<typeof ScrollView>.
Pass an onRefresh that returns a promise, or nothing for synchronous work; the spinner waits for the promise. The haptic plays only if the app provides an adapter through HapticsProvider.
PullToRefresh
A ScrollView with built-in pull to refresh.
| Parameter | Type | Default |
|---|---|---|
onRefresh | () async -> Void | - |
content | () -> Content | - |
.pullToRefresh
| Parameter | Type | Default |
|---|---|---|
_ย action | () async -> Void | - |
PullToRefreshPhase
Values: Idle, Pulling, Refreshing, Settling.
PullToRefresh
A ScrollView with built-in pull to refresh.
| Parameter | Type | Default |
|---|---|---|
onRefresh | suspend () -> Unit | - |
modifier | Modifier | Modifier |
enabled | Boolean | true |
refreshLabel | String | "Refresh" |
content | @Composable () -> Unit | - |
refreshing | Boolean | - |
Overloads: PullToRefresh(onRefresh, content), PullToRefresh(refreshing, onRefresh, content).
