> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# `<refresh>`

Pull-to-refresh: pulling down on its content reveals a header you design, then fires an event so you can reload.


## Usage

```typescript title="src/app/feed.ts"
import { Component, ElementRef, viewChild } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-feed',
  imports: [LYNX_ELEMENTS],
  template: `
    <refresh
      #refresher
      style="width: 100%; height: 100%;"
      (bindstartrefresh)="reload()"
    >
      <refresh-header>
        <view
          style="height: 60px; align-items: center; justify-content: center;"
        >
          <text>Refreshing…</text>
        </view>
      </refresh-header>
      <scroll-view
        scroll-orientation="vertical"
        style="width: 100%; height: 100%;"
      >
        <text>Pull down</text>
      </scroll-view>
    </refresh>
  `,
})
export class Feed {
  readonly refresher = viewChild.required('refresher', { read: ElementRef });

  reload(): void {
    // Load your data, then hide the header: it stays open until finishRefresh.
    this.refresher().nativeElement.invoke?.('finishRefresh');
  }
}
```

Import `LYNX_ELEMENTS` in your component (see [Elements](/api/angular-lynx/elements/index.md)).

:::warning
Needs [XElement](/guide/glossary.md#xelement) in custom native apps (see [Embedding](/guide/embedding/index.md)).
:::

## Attributes

| Attribute        | Type      | Default | Description                                                            |
| ---------------- | --------- | ------- | ---------------------------------------------------------------------- |
| `enable-refresh` | `boolean` | `true`  | Whether pulling down, or calling `autoStartRefresh`, starts a refresh. |

Plus the [common attributes](/api/elements/view.md#attributes), such as `id`, `class` and `style`.

## Events

Read the payload from `$event.detail`. Angular types `$event` for each event: see [Element events](/api/angular-lynx/element-events.md#other-elements).

| Event                    | `detail`                                         | Description                                                                                                          |
| ------------------------ | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| `bindstartrefresh`       | `{ isManual: boolean }`                          | A refresh started. `isManual` is `true` when the user pulled. Reload, then call `finishRefresh`.                     |
| `bindheaderoffset`       | `{ isDragging: boolean; offsetPercent: number }` | The header moved. `offsetPercent` is the pull distance divided by the header's height. Use it to animate the header. |
| `bindrefreshstatechange` | `{ state: 0 \| 1 \| 2 }`                         | The header's state changed: `0` idle, `1` pulled far enough to release, `2` refreshing.                              |

Plus the [common events](/api/elements/view.md#events), such as `bindtap`.

## Methods

These **UI methods** ([Glossary](/guide/glossary.md#ui-method)) start and end a refresh from code. Call them with `invoke()` on the element (see [Call element methods](/guide/selector-query.md)), as the [Usage](#usage) example does with `finishRefresh`.

| Method             | Parameters | Description                                                                           |
| ------------------ | ---------- | ------------------------------------------------------------------------------------- |
| `finishRefresh`    | —          | Ends the refresh, and the header slides away. Call it after every `bindstartrefresh`. |
| `autoStartRefresh` | —          | Shows the whole header and fires `bindstartrefresh`, as if the user had pulled.       |

## Children

Give `<refresh>` two direct children, in this order:

1. **`<refresh-header>`**: the header the pull reveals.
2. **One scrollable element**, such as a [`<scroll-view>`](/api/elements/scroll-view.md) or a [`<list>`](/api/elements/list.md).

Only vertical pulls are supported.

**Give `<refresh>` a size**, as the [Usage](#usage) example does. It doesn't size itself from its children, so without a width and height it draws nothing on iOS and Android.

## Related

- [`<scroll-view>`](/api/elements/scroll-view.md) and [`<list>`](/api/elements/list.md)
- [`<scroll-coordinator>`](/api/elements/scroll-coordinator.md): refresh a page with a collapsing header
- [Call element methods](/guide/selector-query.md)
