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
| Name | Description | Type | Default |
|---|---|---|---|
| modelValue | Refreshing (controlled) | boolean | false |
| headHeight | Head height / trigger threshold px | number | 50 |
| pullingText | Pulling hint (defaults to locale pullRefresh.pulling) | string | — |
| loosingText | Release hint (defaults to locale pullRefresh.loosing) | string | — |
| loadingText | Loading hint (defaults to locale pullRefresh.loading) | string | — |
| successText | Success hint (defaults to locale pullRefresh.success) | string | — |
| disabled | Disable pull | boolean | false |
| sx | Quick layout props | LhSxProps | — |
| children | Page content (plus default slot) | ReactNode | — |
| headSlot | Custom head (plus #head slot) | ReactNode | — |
Events
| Name | Description | Type |
|---|---|---|
| onChange | Refreshing state change (write-back path for modelValue) | (value: boolean) => void |
| onRefresh | Released 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 aheadSlotReactNode prop - uniapp / wxapp: scroll-view refresher event mapping (no manual gestures); alipay uses page-level onPullDownRefresh (see each platform's docs)