# Pull refresh

Pull to refresh you can feel arming: a ring draws as you pull and closes at the line.

Also called: pull to refresh.

Example: Pull to refresh you can feel arming. Pull the list down and it gives less the further you go; a ring draws round the arrow and, at the line, closes and turns blue. Let go and it spins, checks green and springs back. Preview: https://chatcn.dev/preview/pull-refresh-demo

Drag the list down from the top and it gives less the further you go. A ring draws round the arrow as you pull; at the line it closes, the arrow turns over and the ring takes colour, so you know letting go will do it. Let go and the ring spins while it loads, closes into a check and the list springs back up.

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/pull-refresh.json
```

## Usage

```tsx
import { PullRefresh } from "@/components/ui/chatcn/pull-refresh"

<PullRefresh className="h-[480px]" onRefresh={() => refetch()}>
  <ThreadList />
</PullRefresh>
```

Pulling is a gesture, so keep a refresh control elsewhere for keyboard and screen reader users.

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `onRefresh` | `() => Promise<unknown>` | The ring spins until it settles |
| `threshold` | `number` | Px to pull before letting go refreshes. Default 72 |

## Accessibility

- Refreshing and Up to date are announced politely.

## Motion

- A `tanh` rubber band; the release rides a spring. Touch uses native listeners so normal scrolling is untouched.

Source: https://chatcn.dev/docs/components/pull-refresh