Feedback
PullToRefresh
Pull-down-to-refresh for touch devices. Calls onRefresh after a long enough pull at the top of the page and shows a spinner until isFetching turns false.
import { PullToRefresh } from "datui";Examples
Basic
On a touch device pull the list down. With a keyboard, Tab to the Refresh button that appears on focus.
- First post
- Second post
- Third post
Accessibility
- Wraps content in a
role="region"labelled byaria-label(default "Refreshable content") witharia-busywhile refreshing. - The gesture only runs for touch; mouse drags do nothing. Keyboard and screen-reader users get a visually hidden Refresh button (
refreshLabel) that becomes visible on focus and is disabled while refreshing. - A polite status announces
refreshingLabelwhile refreshing. The spinner itself is decorative. - The spinner stays for at least one second so a fast refresh doesn't flash; content movement has no transition under
prefers-reduced-motion.
API
PullToRefresh
Touch pull-down-to-refresh around page content. Mouse and keyboard users get a refresh button that appears on focus; the gesture only runs for touch.
| Prop | Type | Default | Description |
|---|---|---|---|
| onRefresh (required) | () => void | — | Called once per completed pull, or when the refresh button is activated. |
| aria-label | string | Refreshable content | Accessible name of the region. |
| className | string | — | |
| isFetching | boolean | false | Set while data loads; the spinner stays until it turns false (and for at least a short moment). |
| refreshingLabel | string | Refreshing… | Announced while refreshing. |
| refreshLabel | string | Refresh | Label of the refresh button shown to keyboard and assistive-tech users. |