# Content Loaders

## Content Loader

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.&#x20;

![](https://3608702775-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsQWILyBp_9nWmIJ7TG%2F-LubTxjVuKSYrGxVjLpS%2F-LubUHBEq45sYcxzOz-w%2Fassets_-La-kqVz2Uq1Ka0VUWZT_-LakgKPNQf4bocIoGYQg_-Lakh2Xb2YtDtasrxfKa_Screen%20Shot%202019-03-24%20at%2010.44.30%20PM.png?alt=media\&token=fc38e8c8-669c-4f14-abd2-9d4ec168386d)

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

{% hint style="info" %}
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 ! )
{% endhint %}

### Type 1 - ion-skeleton-text (recommended)

It is located in `src/app/pages/addons/content-loader2` .&#x20;

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

```
<ion-list-header>
  <ion-skeleton-text animated style="width: 20%"></ion-skeleton-text>
</ion-list-header>
```

You can assign CSS properties like `width` , `height` and `border-radius` to create different shaped for the loading data

### Type 2 - ngx-content-loader

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.&#x20;

In Full App it is located in `src/app/pages/addons/content-loader` .&#x20;

As an example, see the following

```
<div class="loader">
  <content-loader>
    <svg:rect x="15" y="15" rx="1" ry="1" width="60" height="60" />
    <svg:rect x="90" y="25" rx="3" ry="3" width="260" height="15" />
    <svg:rect x="90" y="45" rx="3" ry="3" width="150" height="15" />
  </content-loader>
</div>
```

To install the library, you need to run&#x20;

```
$ npm i @netbasal/ngx-content-loader --save
```

Import it in your module using

```
import { ContentLoaderModule } from '@netbasal/ngx-content-loader';
```

and include in the module imports as

```
@NgModule({
  ....,
  imports: [ContentLoaderModule, ...],
  ....
})
```

More details on this library are available in the [Github repository](https://github.com/NetanelBasal/ngx-content-loader)

### API Example

To illustrate the real usage, we have implemented an API call with 5000ms delay in the `API usage` segment of the `content-loader` page.

![](https://3608702775-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsQWILyBp_9nWmIJ7TG%2F-LubTxjVuKSYrGxVjLpS%2F-LubUHBEq45sYcxzOz-w%2Fassets_-La-kqVz2Uq1Ka0VUWZT_-LakgKPNQf4bocIoGYQg_-Lakh2Xb2YtDtasrxfKa_Screen%20Shot%202019-03-24%20at%2010.44.30%20PM.png?alt=media\&token=fc38e8c8-669c-4f14-abd2-9d4ec168386d)

![](https://3608702775-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LsQWILyBp_9nWmIJ7TG%2F-LubTxjVuKSYrGxVjLpS%2F-LubUHBIMye8S6f7sNFB%2Fassets_-La-kqVz2Uq1Ka0VUWZT_-LakgKPNQf4bocIoGYQg_-Lakh6hqtYoz0gBUtJyE_Screen%20Shot%202019-03-24%20at%2010.44.39%20PM.png?alt=media\&token=144ee24a-d13d-4705-8f8b-361c4e456e7b)
