PullToRefresh
Content that is refreshed when it is pulled down from the top, such as a feed, with a spinner while it refreshes and a Refresh button that does the same.
Stability: experimental
Props
| Prop | Type | Default | Means |
|---|---|---|---|
label | string | "Refresh" | The Refresh button's text. |
refreshing | boolean | bindable(false) | Whether a refresh is running. It is set while onRefresh runs; bind it with bind:refreshing={name} to show one started elsewhere. |
onRefresh | () => void | Promise<void> | Refreshes the content; the spinner shows until the promise it returns settles. A pull while one runs starts none. |
Children
The content that is refreshed.
States
| State | Looks like |
|---|---|
idle | A small Refresh button above the content. |
refreshing | A spinner in place of the button, and the status reads Refreshing. |
Accessibility
| role | status for the refreshing message; the button is a button |
| name | The label prop names the button; the spinner is named Refreshing. |
| focus | Tab reaches the Refresh button, then the content. |
| keyboard | Enter and Space press Refresh. |
| notes | A swipe down counts only while what scrolls around it is at the top, so scrolling up a feed never refreshes it. The pull is never the only way: the button does the same. |
Theme tokens
color.muted space.2 space.3 radius.full text.caption
Example
<PullToRefresh onRefresh={reload}><List items={posts} /></PullToRefresh>