ion-loading
An overlay that can be used to indicate activity while blocking user interaction. The loading indicator appears on top of the app's content, and can be dismissed by the app to resume user interaction with the app. It includes an optional backdrop, which can be disabled by setting showBackdrop: false
upon creation.
#
DismissingThe loading indicator can be dismissed automatically after a specific amount of time by passing the number of milliseconds to display it in the duration
of the loading options. To dismiss the loading indicator after creation, call the dismiss()
method on the loading instance. The onDidDismiss
function can be called to perform an action after the loading indicator is dismissed.
#
CustomizationLoading uses scoped encapsulation, which means it will automatically scope its CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a higher specificity selector.
We recommend passing a custom class to cssClass
in the create
method and using that to add custom styles to the host and inner elements. This property can also accept multiple classes separated by spaces. View the Usage section for an example of how to pass a class using cssClass
.
Any of the defined CSS Custom Properties can be used to style the Loading without needing to target individual elements:
If you are building an Ionic Angular app, the styles need to be added to a global stylesheet file. Read Style Placement in the Angular section below for more information.
#
Usage- ANGULAR
- JAVASCRIPT
- REACT
- STENCIL
- VUE
#
Style PlacementIn Angular, the CSS of a specific page is scoped only to elements of that page. Even though the Loading can be presented from within a page, the ion-loading
element is appended outside of the current page. This means that any custom styles need to go in a global stylesheet file. In an Ionic Angular starter this can be the src/global.scss
file or you can register a new global style file by adding to the styles
build option in angular.json
.
Developers can also use this component directly in their template:
#
Properties#
animatedDescription | If true , the loading indicator will animate. |
Attribute | animated |
Type | boolean |
Default | true |
#
backdropDismissDescription | If true , the loading indicator will be dismissed when the backdrop is clicked. |
Attribute | backdrop-dismiss |
Type | boolean |
Default | false |
#
cssClassDescription | Additional classes to apply for custom CSS. If multiple classes are provided they should be separated by spaces. |
Attribute | css-class |
Type | string \| string[] \| undefined |
Default | undefined |
#
durationDescription | Number of milliseconds to wait before dismissing the loading indicator. |
Attribute | duration |
Type | number |
Default | 0 |
#
enterAnimationDescription | Animation to use when the loading indicator is presented. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) \| undefined |
Default | undefined |
#
keyboardCloseDescription | If true , the keyboard will be automatically dismissed when the overlay is presented. |
Attribute | keyboard-close |
Type | boolean |
Default | true |
#
leaveAnimationDescription | Animation to use when the loading indicator is dismissed. |
Attribute | undefined |
Type | ((baseEl: any, opts?: any) => Animation) \| undefined |
Default | undefined |
#
messageDescription | Optional text content to display in the loading indicator. |
Attribute | message |
Type | IonicSafeString \| string \| undefined |
Default | undefined |
#
modeDescription | The mode determines which platform styles to use. |
Attribute | mode |
Type | "ios" \| "md" |
Default | undefined |
#
showBackdropDescription | If true , a backdrop will be displayed behind the loading indicator. |
Attribute | show-backdrop |
Type | boolean |
Default | true |
#
spinnerDescription | The name of the spinner to display. |
Attribute | spinner |
Type | "bubbles" \| "circles" \| "circular" \| "crescent" \| "dots" \| "lines" \| "lines-sharp" \| "lines-sharp-small" \| "lines-small" \| null \| undefined |
Default | undefined |
#
translucentDescription | If true , the loading indicator will be translucent.Only applies when the mode is "ios" and the device supportsbackdrop-filter . |
Attribute | translucent |
Type | boolean |
Default | false |
#
EventsName | Description |
---|---|
ionLoadingDidDismiss | Emitted after the loading has dismissed. |
ionLoadingDidPresent | Emitted after the loading has presented. |
ionLoadingWillDismiss | Emitted before the loading has dismissed. |
ionLoadingWillPresent | Emitted before the loading has presented. |
#
Methods#
dismissDescription | Dismiss the loading overlay after it has been presented. |
Signature | dismiss(data?: any, role?: string \| undefined) => Promise<boolean> |
#
onDidDismissDescription | Returns a promise that resolves when the loading did dismiss. |
Signature | onDidDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
#
onWillDismissDescription | Returns a promise that resolves when the loading will dismiss. |
Signature | onWillDismiss<T = any>() => Promise<OverlayEventDetail<T>> |
#
presentDescription | Present the loading overlay after it has been created. |
Signature | present() => Promise<void> |
#
CSS Custom PropertiesName | Description |
---|---|
--backdrop-opacity | Opacity of the backdrop |
--background | Background of the loading dialog |
--height | Height of the loading dialog |
--max-height | Maximum height of the loading dialog |
--max-width | Maximum width of the loading dialog |
--min-height | Minimum height of the loading dialog |
--min-width | Minimum width of the loading dialog |
--spinner-color | Color of the loading spinner |
--width | Width of the loading dialog |