Content Loaders
When the API response takes time, you want to show a content loader that matches your content UI, just like Facebook feed
Last updated
When the API response takes time, you want to show a content loader that matches your content UI, just like Facebook feed
Last updated
Also called Skeleton Text in ionic, it is used to show a loading data, but showing the tentative layout of the incoming structure. This looks more pleasing to the user, as user feels that the information is already in and will be displayed any second.
We have included two types of content loaders in the Full App, one using the Ionic's default ion-skeleton-text
and another one using Angular's ngx-content-loader
library
In both types of content loaders, you need to know beforehand what is the layout of your data going to be (which you will know any way because it is your app ! )
It is located in src/app/pages/addons/content-loader2
.
The way to show the skeleton text while the data is loading uses a standard *ngIf
logic - when data is loading , show the skeleton text. Once the data is loaded, hide the skeleton text and show actual data. But to the user, it appears like both were connected somehow because the layout seems very similar.
You can see in content-loader2.page.html
, there are two div
depending on a variable data
The skeleton text is just another div which has a gray-ish background, and the background displays a dynamic loader like animation. This gives the feel of a loading content.
E.g. The list header is loaded like this
You can assign CSS properties like width
, height
and border-radius
to create different shaped for the loading data
This is very similar to ion-skeleton-text
except the fact that it is not included in ionic package. It is more flexible that ion-skeleton-text
as you can define the origin points, width, height and two radii of the content loader SVG div.
In Full App it is located in src/app/pages/addons/content-loader
.
As an example, see the following
To install the library, you need to run
Import it in your module using
and include in the module imports as
More details on this library are available in the Github repository
To illustrate the real usage, we have implemented an API call with 5000ms delay in the API usage
segment of the content-loader
page.