datui
Color scheme

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 by aria-label (default "Refreshable content") with aria-busy while 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 refreshingLabel while 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.

PropTypeDefaultDescription
onRefresh (required)() => void—Called once per completed pull, or when the refresh button is activated.
aria-labelstringRefreshable contentAccessible name of the region.
classNamestring—
isFetchingbooleanfalseSet while data loads; the spinner stays until it turns false (and for at least a short moment).
refreshingLabelstringRefreshing…Announced while refreshing.
refreshLabelstringRefreshLabel of the refresh button shown to keyboard and assistive-tech users.