Pull to Refresh
Pull to Refresh reports a refresh request while the application owns data fetching and replacement.
Practical React example
Refresh a touch-oriented activity list without removing its last useful content.
Before you copy and paste
Keep the example in the React rendering environment required by the imported component. Copy components/motion/pull-to-refresh.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: clsx, lucide-react, motion, react, tailwind-merge.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Refresh a touch-oriented activity list without removing its last useful content
// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";
import { Bell, CheckCircle2, GitPullRequest, MessageCircle } from "lucide-react";
import { useState } from "react";
import { PullToRefresh } from "@/components/motion/pull-to-refresh";
const initialUpdates = [
{
id: 1,
icon: GitPullRequest,
title: "Motion review approved",
detail: "The pull request is ready to merge.",
time: "4m",
},
{
id: 2,
icon: MessageCircle,
title: "New component feedback",
detail: "The spring feels much closer to native now.",
time: "18m",
},
{
id: 3,
icon: CheckCircle2,
title: "Registry checks passed",
detail: "All component files resolved successfully.",
time: "31m",
},
{
id: 4,
icon: Bell,
title: "Preview deployed",
detail: "The latest build is ready to inspect.",
time: "1h",
},
{
id: 5,
icon: MessageCircle,
title: "Docs comment resolved",
detail: "The usage example now covers async refreshes.",
time: "2h",
},
] as const;
export function PullToRefreshPreview() {
const [refreshCount, setRefreshCount] = useState(0);
const [latestUpdate, setLatestUpdate] = useState<number | null>(null);
const updates = latestUpdate
? [
{
id: latestUpdate,
icon: Bell,
title: "You’re all caught up",
detail: "The activity feed was refreshed just now.",
time: "now",
},
...initialUpdates,
]
: initialUpdates;
return (
<div className="flex min-h-[34rem] w-full items-center justify-center p-4">
<div className="w-full max-w-sm overflow-hidden rounded-[2rem] border border-border bg-background shadow-2xl">
<PullToRefresh
ariaLabel="Activity feed"
className="h-[30rem]"
onRefresh={async () => {
await new Promise((resolve) => setTimeout(resolve, 900));
const next = refreshCount + 1;
setRefreshCount(next);
setLatestUpdate(Date.now());
}}
>
<header className="sticky top-0 z-10 flex items-center justify-between border-b border-border bg-background/90 px-5 py-4 backdrop-blur-md">
<div>
<p className="font-semibold text-foreground">Activity</p>
<p className="text-xs text-muted-foreground">
Pull down to check for updates
</p>
</div>
<span className="rounded-full bg-muted px-2.5 py-1 font-mono text-[10px] text-muted-foreground">
{refreshCount ? `${refreshCount} refreshed` : "live"}
</span>
</header>
<div className="divide-y divide-border px-2 pb-3">
{updates.map((update) => {
const Icon = update.icon;
return (
<article key={update.id} className="flex gap-3 px-3 py-4">
<div className="grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-border bg-card text-muted-foreground shadow-sm">
<Icon className="h-4 w-4" />
</div>
<div className="min-w-0 flex-1">
<div className="flex items-start justify-between gap-3">
<p className="text-sm font-medium text-foreground">
{update.title}
</p>
<span className="shrink-0 font-mono text-[10px] text-muted-foreground">
{update.time}
</span>
</div>
<p className="mt-1 text-xs leading-relaxed text-muted-foreground">
{update.detail}
</p>
</div>
</article>
);
})}
</div>
</PullToRefresh>
</div>
</div>
);
}
Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.
Return the real refresh promise from onRefresh and handle failures in your data layer. Keep the old list available while a refresh is pending.
Customization
- PullToRefreshProps.onRefresh
- Required; () => void | Promise<void>. Runs after the user pulls beyond the threshold and releases.
- PullToRefreshProps.children
- Required; ReactNode.
- PullToRefreshProps.refreshing
- Optional; boolean. Keeps the indicator active while an externally managed refresh runs.
- PullToRefreshProps.disabled
- Optional; boolean.
- PullToRefreshProps.threshold
- Optional; number. Resisted pull distance in pixels required to refresh.
- PullToRefreshProps.maxPull
- Optional; number. Maximum resisted pull distance in pixels.
- PullToRefreshProps.holdDistance
- Optional; number. Content offset in pixels while refreshing.
- PullToRefreshProps.pullingLabel
- Optional; ReactNode.
- PullToRefreshProps.releaseLabel
- Optional; ReactNode.
- PullToRefreshProps.refreshingLabel
- Optional; ReactNode.
- PullToRefreshProps.ariaLabel
- Optional; string.
- PullToRefreshProps.className
- Optional; string.
- PullToRefreshProps.contentClassName
- Optional; string.
- PullToRefreshProps.indicatorClassName
- Optional; string.
Integration notes
- Offer a visible refresh button as an alternative to the pull gesture.
- Avoid stacking competing scroll containers or overriding native browser behavior without testing it.
Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.
Give your agent taste.
The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.
All components are free. Sign up only to connect MCP.