Skip to main content

PullRefresh

Pull to refresh: a gesture state machine pulling → loosing → loading → success. The distance damping (dampenPull) and top detection (canPull) are all pure functions consumed from @lh-ui/share/core/pull-refresh; the success hint auto-resets after 500ms.

Basic usage​

Pull to refresh (release to trigger + success hint)
Pull down to refresh
Item 1
Item 2
Item 3

3 items · Refreshed 0 times

import { useState } from 'react'
import { LhPullRefresh } from '@lh-ui/react'

export default function Demo() {
const [refreshing, setRefreshing] = useState(false)
const [items, setItems] = useState([1, 2, 3])

const onRefresh = () => {
setTimeout(() => {
setItems([1, 2, 3].map((i) => i + 3))
setRefreshing(false)
}, 800)
}

return (
<LhPullRefresh modelValue={refreshing} onChange={setRefreshing} onRefresh={onRefresh}>
{items.map((item) => (
<div key={item}>Item {item}</div>
))}
</LhPullRefresh>
)
}

Custom head​

headSlot replaces the default text hint:

<LhPullRefresh modelValue={refreshing} onChange={setRefreshing}
headSlot={<span>{refreshing ? 'Loading…' : 'Pull to refresh'}</span>}
>
<div>Content</div>
</LhPullRefresh>

Disabled​

<LhPullRefresh modelValue={false} disabled />

PullRefresh API​

Props​

NameDescriptionTypeDefault
modelValueRefreshing (controlled)booleanfalse
headHeightHead height / trigger threshold pxnumber50
pullingTextPulling hint (defaults to locale pullRefresh.pulling)string—
loosingTextRelease hint (defaults to locale pullRefresh.loosing)string—
loadingTextLoading hint (defaults to locale pullRefresh.loading)string—
successTextSuccess hint (defaults to locale pullRefresh.success)string—
disabledDisable pullbooleanfalse
sxQuick layout propsLhSxProps—
childrenPage content (plus default slot)ReactNode—
headSlotCustom head (plus #head slot)ReactNode—

Events​

NameDescriptionType
onChangeRefreshing state change (write-back path for modelValue)(value: boolean) => void
onRefreshReleased past threshold: set modelValue=false after fetching() => void

Accessibility​

  • The root element reflects loading via aria-busy

Differences across platforms​

  • plus / vue2: v-model write-back + touch gestures, head is a named slot
  • React: v-model splits into modelValue + onChange, head is a headSlot ReactNode prop
  • uniapp / wxapp: scroll-view refresher event mapping (no manual gestures); alipay uses page-level onPullDownRefresh (see each platform's docs)