import { Component } from '@angular/core';
import { WrPullToRefresh } from 'ngwr/pull-to-refresh';
@Component({ imports: [WrPullToRefresh] })
export class MyComponent {}Pull to Refresh
Pull down from the top of a scrolling list to refresh it.
Installation
Import the class, and @use the entry point in your global styles: without it the component renders unstyled.
Basic
Start the fetch on (refresh) and keep refreshing true until it settles; the button does the same without touch.
<wr-pull-to-refresh
style="height: 16rem"
[refreshing]="loading()"
(refresh)="reload()"
>
@for (item of items(); track item) {
<div class="row">{{ item }}</div>
}
</wr-pull-to-refresh>protected readonly loading = signal(false);
reload(): void {
this.loading.set(true);
this.api.fetch().subscribe((rows) => {
this.items.set(rows);
this.loading.set(false); // clearing `refreshing` closes the indicator
});
}API
| Name | Description | Type | Default |
|---|---|---|---|
refreshing | Shows the spinner. Set it in refresh and clear it when the work settles. | boolean | false |
threshold | Pull distance (px) a release must reach to trigger. | number | 64 |
disabled | Disable the gesture entirely. | boolean | false |
(refresh) | Fires when the user pulls past threshold and releases. | void | — |
CSS variables
Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/pull-to-refresh's own element.
| Variable | Default | Declared on |
|---|---|---|
--wr-pull-to-refresh-font-family | var(--wr-font-family-base) | .wr-pull-to-refresh |
Dependencies
| Built on | Spinner |
|---|