Utilities
PullToRefresh
PullToRefresh adds the pull to refresh gesture to a page or any scrollable element. It engages only while the scroller is at its top - or at its bottom, for a pull up - damps the pull, and holds an indicator open until the refresh is done - by touch, by mouse, or from code.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Behavior
Direction
Scroller and full width
body
hangs the gesture off the page. A nested scroller that is not at its own top keeps the drag for itself.
FullWidth fills the layout region instead of shrink-wrapping the content.
BlazorUI
States and templates
Programmatic refresh
Events
Disabled and touch only
Cascading parameters
Color
Style & Class
:root re-skins every instance
and one on Style a single one, like the right-hand one here.
RTL
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle that one alone. Leave a variable unset and the component falls back to the theme token beside it.
BitPullToRefresh CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-PullToRefresh-color | --bit-clr-fg-pri | Color of the glyph. The Color and CustomColor parameters win over it. |
| --bit-PullToRefresh-pull-opacity | 0.6 | Opacity of the glyph while the pull falls short of the trigger; it is full once releasing would refresh. |
| --bit-PullToRefresh-indicator-size | --bit-siz-ctrl-md | Diameter of the indicator's disc at the trigger; below it, the disc is drawn at the fraction of it the pull has come. |
| --bit-PullToRefresh-glyph-size | --bit-siz-icon-lg | Size of the glyph inside the disc at the trigger, scaled with the pull the same way. |
| --bit-PullToRefresh-indicator-background | --bit-clr-bg-pri | Fill of the disc. |
| --bit-PullToRefresh-indicator-shadow | --bit-shd-popup | Elevation of the disc. |
| --bit-PullToRefresh-indicator-radius | --bit-shp-radius-full | Corners of the disc. |
| --bit-PullToRefresh-refreshing-background | --bit-clr-bg-ter | Fill of the disc while the refresh runs. |
| --bit-PullToRefresh-complete-background | --bit-PullToRefresh-refreshing-background | Fill of the disc in the complete state. |
| --bit-PullToRefresh-strip-background | transparent | Fill of the strip the pull opens over the top of the anchor. |
| --bit-PullToRefresh-z-index | 1 | Layer of the strip over the anchor's content, to lift it above a sticky header inside it. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitPullToRefresh parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Anchor | RenderFragment? | null | The anchor element that the pull to refresh component adheres to (alias of ChildContent). |
| ChildContent | RenderFragment? | null | The anchor element that the pull to refresh component adheres to. |
| Classes | BitPullToRefreshClassStyles? | null | Custom CSS classes for different parts of the BitPullToRefresh. |
| Color | BitColor? | null | The general color of the pull indicator. It colors the glyph inside the indicator's disc, which the pull, the refresh and the complete states all draw. |
| Complete | RenderFragment? | null | The custom template to replace the default checkmark svg shown while the complete state is visible. |
| CompleteDelay | int | 0 | The duration in milliseconds to keep the complete indicator visible after a successful refresh before snapping back (0 disables the complete state). It is skipped when OnRefresh throws. |
| CompleteLabel | string | Refresh complete | The text that gets announced to screen readers while the complete state is visible after a successful refresh. |
| CustomColor | string? | null | The custom css color of the pull indicator. It only applies while Color is left unset. |
| Direction | BitPullToRefreshDirection | BitPullToRefreshDirection.Down | The direction the pull travels in to refresh. Down engages while the scroller is at its top and opens the strip over the top of the anchor; Up engages while it is at its bottom and opens the strip over the bottom of the anchor. The trigger, factor, margin, threshold and overpull are measured along the chosen direction, and the reported pull height is never negative. |
| Factor | decimal | 1.5 | The factor to balance the pull height out. The pull-down distance gets divided by it, so higher values make the pull feel heavier. Values below 0.1 are treated as 0.1. |
| FullWidth | bool | false | Whether the component takes the whole width of its container instead of shrink-wrapping its anchor. |
| IndicatorTemplate | RenderFragment<BitPullToRefreshIndicatorContext>? | null | The custom template to replace the whole indicator - the disc and the glyph inside it. It gets the State and the PullProgress of the gesture, is drawn unscaled and unturned in the middle of the strip (which makes it the one for a text indicator), and takes over from Loading, Release and Complete. While it is set, the component re-renders for every pixel of a pull. |
| Loading | RenderFragment? | null | The custom loading template to replace the default loading svg. It is what the indicator shows while the pull is under way and while the refresh is running, so it covers every state that Release and Complete do not take over. It scales with the pull, so size it in relative units. |
| Margin | int | 30 | The value in pixel to add to the top of pull element as a margin for the pull height. |
| MaxPull | int | 0 | The furthest the pull can travel, in pixels, past which it stops following the finger; 0 stops it at Trigger. The indicator holds its full size over that stretch, and only the strip keeps growing. It is measured on the same damped scale as Trigger. |
| NoMouse | bool | false | Leaves the mouse out of the gesture, so that only touch and pen pull to refresh. A mouse or pen drag that starts on a form field or editable content is left to it either way. |
| OnPullCancel | EventCallback<decimal> | The callback for when the pull-down gets canceled before release, providing the last pull height. | |
| OnPullEnd | EventCallback<decimal> | The callback for the ending of the pull-down. | |
| OnPullMove | EventCallback<decimal> | The callback for when the pull-down is in progress, reporting the pull height in pixels, which is capped at Trigger - or at MaxPull where the pull is allowed past it. The reports are coalesced to at most one per frame and never repeat a whole pixel. | |
| OnPullStart | EventCallback<BitPullToRefreshPullStartArgs> | The callback for the starting of the pull-down. | |
| OnRefresh | EventCallback | The callback for when the trigger condition of the pull-down happens. | |
| OnStateChange | EventCallback<BitPullToRefreshState> | The callback for when the gesture moves on to another stage, reported once per change. It is the one callback that hears the refresh end, since the parent re-renders for OnRefresh before the indicator closes. The gesture does not wait for it, so a slow handler never holds up the refresh; an exception it throws goes to the error boundary. | |
| RefreshingLabel | string | Refreshing | The text that gets announced to screen readers while the refresh is in progress. |
| Release | RenderFragment? | null | The custom template to replace the glyph while the pull has passed the trigger and releasing starts the refresh. Without it, the Loading glyph is drawn there at full strength instead of faded. |
| ReleaseLabel | string | Release to refresh | The text that gets announced to screen readers while the pull has passed the trigger and releasing starts the refresh. An empty string leaves the release state unannounced. |
| ScrollerElement | ElementReference? | null | The element that is the scroller in the anchor to control the behavior of the pull to refresh. |
| ScrollerSelector | string? | null | The CSS selector of the element that is the scroller in the anchor to control the behavior of the pull to refresh. It is looked up inside the anchor first and in the document afterwards, so "body" hangs the gesture off the page; left unset, the first element of the anchor is taken as the scroller. |
| Styles | BitPullToRefreshClassStyles? | null | Custom CSS styles for different parts of the BitPullToRefresh. |
| Threshold | int | 0 | The dead-zone distance in pixel that the pull-down must travel before the pull to refresh process starts and the indicator appears. |
| Trigger | int | 80 | The pulling height in pixel that triggers the refresh. It is also the distance the indicator grows to its full size over. Values below 1 are treated as 1. |
BitPullToRefresh public members
| Name | Type | Default value | Description |
|---|---|---|---|
| IsRefreshing | bool | false | Whether a refresh is currently running - the pull was released past the trigger, or RefreshAsync was called, and the OnRefresh callback has not returned yet. |
| PullProgress | decimal | 0 | How far the current pull has come as a fraction of Trigger: 0 while nothing is being pulled, and 1 once releasing would start a refresh. It reads 1 for the whole of a refresh. |
| State | BitPullToRefreshState | Idle | The stage of the gesture the component is at: idle, pulling, past the trigger, refreshing or complete. OnStateChange reports every change of it. |
| RefreshAsync | Task | Starts the refresh process programmatically, showing the loading indicator and invoking the OnRefresh callback. It has no effect while the component is disabled, a refresh is already in progress or the complete state is visible. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitPullToRefreshPullStartArgs properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Top | decimal | The top offset of the pull to refresh element in pixels. | |
| Left | decimal | The left offset of the pull to refresh element in pixels. | |
| Width | decimal | The width of the pull to refresh element in pixels. |
BitPullToRefreshIndicatorContext properties
| Name | Type | Default value | Description |
|---|---|---|---|
| State | BitPullToRefreshState | The stage of the gesture the component is at: idle, pulling, past the trigger, refreshing or complete. | |
| Progress | decimal | How far the pull has come as a fraction of the trigger: 0 while nothing is being pulled, and 1 once releasing would start a refresh, for the whole of the refresh and in the complete state. |
BitPullToRefreshClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the PullToRefresh. |
| Loading | string? | null | Custom CSS classes/styles for the loading element. |
| SpinnerWrapper | string? | null | Custom CSS classes/styles for the spinner wrapper element. |
| SpinnerWrapperCanRelease | string? | null | Custom CSS classes/styles for the spinner wrapper element when the pull passed the trigger and releasing starts the refresh. |
| SpinnerWrapperRefreshing | string? | null | Custom CSS classes/styles for the spinner wrapper element in refreshing mode. |
| SpinnerWrapperComplete | string? | null | Custom CSS classes/styles for the spinner wrapper element while the complete state is visible after a successful refresh. |
| Spinner | string? | null | Custom CSS classes/styles for the spinner element. |
| SpinnerCanRelease | string? | null | Custom CSS classes/styles for the spinner element when the pull passed the trigger and releasing starts the refresh. |
| SpinnerRefreshing | string? | null | Custom CSS classes/styles for the spinner element in refreshing mode. |
| SpinnerComplete | string? | null | Custom CSS classes/styles for the spinner element while the complete state is visible after a successful refresh. |
BitPullToRefreshState enum
| Name | Value | Description |
|---|---|---|
| Idle | 0 | Nothing is being pulled and no refresh is running. |
| Pulling | 1 | A pull is under way but has not reached the trigger, so letting go drops it. |
| CanRelease | 2 | The pull has passed the trigger, so letting go starts the refresh. |
| Refreshing | 3 | The refresh is running: the OnRefresh callback has not returned yet. |
| Complete | 4 | The refresh has finished and the complete indicator is held open for the CompleteDelay. |
BitPullToRefreshDirection enum
| Name | Value | Description |
|---|---|---|
| Down | 0 | Pulled down while the scroller is at its top, opening the strip over the top of the anchor. |
| Up | 1 | Pulled up while the scroller is at its bottom, opening the strip over the bottom of the anchor. |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | Info Primary general color. |
| Secondary | 1 | Secondary general color. |
| Tertiary | 2 | Tertiary general color. |
| Info | 3 | Info general color. |
| Success | 4 | Success general color. |
| Warning | 5 | Warning general color. |
| SevereWarning | 6 | SevereWarning general color. |
| Error | 7 | Error general color. |
| PrimaryBackground | 8 | Primary background color. |
| SecondaryBackground | 9 | Secondary background color. |
| TertiaryBackground | 10 | Tertiary background color. |
| PrimaryForeground | 11 | Primary foreground color. |
| SecondaryForeground | 12 | Secondary foreground color. |
| TertiaryForeground | 13 | Tertiary foreground color. |
| PrimaryBorder | 14 | Primary border color. |
| SecondaryBorder | 15 | Secondary border color. |
| TertiaryBorder | 16 | Tertiary border color. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.