# ion-skeleton-text

URL: https://ionicframework.com/docs/api/skeleton-text

**Encapsulation**: [shadow](/docs/reference/glossary.md#shadow)

Skeleton Text is a component for rendering placeholder content. The element will render a gray block at the specified width.

## Basic Usage

**JavaScript**

`index.html`

```html
<ion-list></ion-list><br />
<ion-button onclick="toggle()">Toggle</ion-button>

<script>
  const list = document.querySelector('ion-list');
  let loaded = false;
  function toggle() {
    if (loaded) {
      setSkeletonText();
    } else {
      setContent();
    }

    loaded = !loaded;
  }

  function setSkeletonText() {
    list.innerHTML = `
      <ion-list-header>
        <ion-skeleton-text animated="true" style="width: 80px"></ion-skeleton-text>
      </ion-list-header>
      <ion-item>
        <ion-thumbnail slot="start">
          <ion-skeleton-text animated="true"></ion-skeleton-text>
        </ion-thumbnail>
        <ion-label>
          <h3>
            <ion-skeleton-text animated="true" style="width: 80%;"></ion-skeleton-text>
          </h3>
          <p>
            <ion-skeleton-text animated="true" style="width: 60%;"></ion-skeleton-text>
          </p>
          <p>
            <ion-skeleton-text animated="true" style="width: 30%;"></ion-skeleton-text>
          </p>
        </ion-label>
      </ion-item>
    `;
  }

  function setContent() {
    list.innerHTML = `
      <ion-list-header>Albums</ion-list-header>
      <ion-item>
        <ion-thumbnail slot="start">
          <ion-icon style="width: 100%; height: 100%" name="musical-notes"></ion-icon>
        </ion-thumbnail>
        <ion-label>
          <h3>Abbey Road</h3>
          <p>The Beatles</p>
          <p>1969</p>
        </ion-label>
      </ion-item>
    `;
  }

  setSkeletonText();
</script>
```

`index.ts`

```ts
import { defineCustomElements } from '@ionic/core/loader';

import { addIcons } from 'ionicons';
import { musicalNotes } from 'ionicons/icons';

/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css';
import '@ionic/core/css/structure.css';
import '@ionic/core/css/typography.css';

/* Optional CSS utils that can be commented out */
import '@ionic/core/css/padding.css';
import '@ionic/core/css/float-elements.css';
import '@ionic/core/css/text-alignment.css';
import '@ionic/core/css/text-transformation.css';
import '@ionic/core/css/flex-utils.css';
import '@ionic/core/css/display.css';

/**
 * Ionic Dark Palette
 * -----------------------------------------------------
 * For more information, please see:
 * https://ionicframework.com/docs/theming/dark-mode
 */

// import '@ionic/core/css/palettes/dark.always.css';
// import '@ionic/core/css/palettes/dark.class.css';
import '@ionic/core/css/palettes/dark.system.css';

/* Theme variables */
import './theme/variables.css';

/**
 * On Ionicons 7.2+ this icon
 * gets mapped to a "musical-notes" key.
 * Alternatively, developers can do:
 * addIcons({ 'musical-notes': musicalNotes });
 */
addIcons({ musicalNotes });

defineCustomElements();
```

**Angular**

`src/app/example.component.html`

```html
@if (loaded) {
<ion-list>
  <ion-list-header>Albums</ion-list-header>
  <ion-item>
    <ion-thumbnail slot="start">
      <ion-icon style="width: 100%; height: 100%" name="musical-notes"></ion-icon>
    </ion-thumbnail>
    <ion-label>
      <h3>Abbey Road</h3>
      <p>The Beatles</p>
      <p>1969</p>
    </ion-label>
  </ion-item>
</ion-list>
} @else {
<ion-list>
  <ion-list-header>
    <ion-skeleton-text [animated]="true" style="width: 80px"></ion-skeleton-text>
  </ion-list-header>
  <ion-item>
    <ion-thumbnail slot="start">
      <ion-skeleton-text [animated]="true"></ion-skeleton-text>
    </ion-thumbnail>
    <ion-label>
      <h3>
        <ion-skeleton-text [animated]="true" style="width: 80%;"></ion-skeleton-text>
      </h3>
      <p>
        <ion-skeleton-text [animated]="true" style="width: 60%;"></ion-skeleton-text>
      </p>
      <p>
        <ion-skeleton-text [animated]="true" style="width: 30%;"></ion-skeleton-text>
      </p>
    </ion-label>
  </ion-item>
</ion-list>
}

<ion-button (click)="loaded = !loaded">Toggle</ion-button>
```

`src/app/example.component.ts`

```ts
import { Component } from '@angular/core';
import {
  IonButton,
  IonIcon,
  IonItem,
  IonLabel,
  IonList,
  IonListHeader,
  IonSkeletonText,
  IonThumbnail,
} from '@ionic/angular';

import { addIcons } from 'ionicons';
import { musicalNotes } from 'ionicons/icons';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonButton, IonIcon, IonItem, IonLabel, IonList, IonListHeader, IonSkeletonText, IonThumbnail],
})
export class ExampleComponent {
  public loaded = false;

  constructor() {
    /**
     * Any icons you want to use in your application
     * can be registered in app.component.ts and then
     * referenced by name anywhere in your application.
     */
    addIcons({ musicalNotes });
  }
}
```

**React**

```tsx
import React, { useState } from 'react';
import {
  IonButton,
  IonIcon,
  IonItem,
  IonLabel,
  IonList,
  IonListHeader,
  IonSkeletonText,
  IonThumbnail,
} from '@ionic/react';
import { musicalNotes } from 'ionicons/icons';
function Example() {
  const [loaded, setLoaded] = useState(false);
  return (
    <>
      {loaded && (
        <IonList>
          <IonListHeader>Albums</IonListHeader>
          <IonItem>
            <IonThumbnail slot="start">
              <IonIcon style={{ width: '100%', height: '100%' }} icon={musicalNotes}></IonIcon>
            </IonThumbnail>
            <IonLabel>
              <h3>Abbey Road</h3>
              <p>The Beatles</p>
              <p>1969</p>
            </IonLabel>
          </IonItem>
        </IonList>
      )}
      {!loaded && (
        <IonList>
          <IonListHeader>
            <IonSkeletonText animated={true} style={{ width: '80px' }}></IonSkeletonText>
          </IonListHeader>
          <IonItem>
            <IonThumbnail slot="start">
              <IonSkeletonText animated={true}></IonSkeletonText>
            </IonThumbnail>
            <IonLabel>
              <h3>
                <IonSkeletonText animated={true} style={{ width: '80%' }}></IonSkeletonText>
              </h3>
              <p>
                <IonSkeletonText animated={true} style={{ width: '60%' }}></IonSkeletonText>
              </p>
              <p>
                <IonSkeletonText animated={true} style={{ width: '30%' }}></IonSkeletonText>
              </p>
            </IonLabel>
          </IonItem>
        </IonList>
      )}
      <IonButton onClick={() => setLoaded(!loaded)}>Toggle</IonButton>
    </>
  );
}
export default Example;
```

**Vue**

```html
<template>
  <ion-list v-if="loaded">
    <ion-list-header>Albums</ion-list-header>
    <ion-item>
      <ion-thumbnail slot="start">
        <ion-icon style="width: 100%; height: 100%" :icon="musicalNotes"></ion-icon>
      </ion-thumbnail>
      <ion-label>
        <h3>Abbey Road</h3>
        <p>The Beatles</p>
        <p>1969</p>
      </ion-label>
    </ion-item>
  </ion-list>

  <ion-list v-if="!loaded">
    <ion-list-header>
      <ion-skeleton-text :animated="true" style="width: 80px"></ion-skeleton-text>
    </ion-list-header>
    <ion-item>
      <ion-thumbnail slot="start">
        <ion-skeleton-text :animated="true"></ion-skeleton-text>
      </ion-thumbnail>
      <ion-label>
        <h3>
          <ion-skeleton-text :animated="true" style="width: 80%;"></ion-skeleton-text>
        </h3>
        <p>
          <ion-skeleton-text :animated="true" style="width: 60%;"></ion-skeleton-text>
        </p>
        <p>
          <ion-skeleton-text :animated="true" style="width: 30%;"></ion-skeleton-text>
        </p>
      </ion-label>
    </ion-item>
  </ion-list>

  <ion-button @click="setLoaded(!loaded)">Toggle</ion-button>
</template>

<script setup lang="ts">
  import {
    IonButton,
    IonIcon,
    IonItem,
    IonLabel,
    IonList,
    IonListHeader,
    IonSkeletonText,
    IonThumbnail,
  } from '@ionic/vue';
  import { musicalNotes } from 'ionicons/icons';
  import { ref } from 'vue';

  const loaded = ref(false);
  const setLoaded = (state: boolean) => (loaded.value = state);
</script>
```

## Theming

### CSS Custom Properties

**JavaScript**

```html
<style>
  ion-skeleton-text {
    --border-radius: 9999px;
    --background: rgba(188, 0, 255, 0.065);
    --background-rgb: 188, 0, 255;
  }
</style>

<ion-list>
  <ion-list-header>
    <ion-skeleton-text animated="true" style="width: 80px"></ion-skeleton-text>
  </ion-list-header>
  <ion-item>
    <ion-thumbnail slot="start">
      <ion-skeleton-text animated="true"></ion-skeleton-text>
    </ion-thumbnail>
    <ion-label>
      <h3>
        <ion-skeleton-text animated="true" style="width: 80%;"></ion-skeleton-text>
      </h3>
      <p>
        <ion-skeleton-text animated="true" style="width: 60%;"></ion-skeleton-text>
      </p>
      <p>
        <ion-skeleton-text animated="true" style="width: 30%;"></ion-skeleton-text>
      </p>
    </ion-label>
  </ion-item>
</ion-list>
```

**Angular**

`src/app/example.component.html`

```html
<ion-list>
  <ion-list-header>
    <ion-skeleton-text [animated]="true" style="width: 80px"></ion-skeleton-text>
  </ion-list-header>
  <ion-item>
    <ion-thumbnail slot="start">
      <ion-skeleton-text [animated]="true"></ion-skeleton-text>
    </ion-thumbnail>
    <ion-label>
      <h3>
        <ion-skeleton-text [animated]="true" style="width: 80%;"></ion-skeleton-text>
      </h3>
      <p>
        <ion-skeleton-text [animated]="true" style="width: 60%;"></ion-skeleton-text>
      </p>
      <p>
        <ion-skeleton-text [animated]="true" style="width: 30%;"></ion-skeleton-text>
      </p>
    </ion-label>
  </ion-item>
</ion-list>
```

`src/app/example.component.css`

```css
ion-skeleton-text {
  --border-radius: 9999px;
  --background: rgba(188, 0, 255, 0.065);
  --background-rgb: 188, 0, 255;
}
```

`src/app/example.component.ts`

```ts
import { Component } from '@angular/core';
import { IonItem, IonLabel, IonList, IonListHeader, IonSkeletonText, IonThumbnail } from '@ionic/angular';

@Component({
  selector: 'app-example',
  templateUrl: 'example.component.html',
  styleUrls: ['example.component.css'],
  imports: [IonItem, IonLabel, IonList, IonListHeader, IonSkeletonText, IonThumbnail],
})
export class ExampleComponent {}
```

**React**

`src/main.tsx`

```tsx
import React from 'react';
import { IonItem, IonLabel, IonList, IonListHeader, IonSkeletonText, IonThumbnail } from '@ionic/react';

import './main.css';

function Example() {
  return (
    <IonList>
      <IonListHeader>
        <IonSkeletonText animated={true} style={{ width: '80px' }}></IonSkeletonText>
      </IonListHeader>
      <IonItem>
        <IonThumbnail slot="start">
          <IonSkeletonText animated={true}></IonSkeletonText>
        </IonThumbnail>
        <IonLabel>
          <h3>
            <IonSkeletonText animated={true} style={{ width: '80%' }}></IonSkeletonText>
          </h3>
          <p>
            <IonSkeletonText animated={true} style={{ width: '60%' }}></IonSkeletonText>
          </p>
          <p>
            <IonSkeletonText animated={true} style={{ width: '30%' }}></IonSkeletonText>
          </p>
        </IonLabel>
      </IonItem>
    </IonList>
  );
}
export default Example;
```

`src/main.css`

```css
ion-skeleton-text {
  --border-radius: 9999px;
  --background: rgba(188, 0, 255, 0.065);
  --background-rgb: 188, 0, 255;
}
```

**Vue**

```html
<template>
  <ion-list>
    <ion-list-header>
      <ion-skeleton-text :animated="true" style="width: 80px"></ion-skeleton-text>
    </ion-list-header>
    <ion-item>
      <ion-thumbnail slot="start">
        <ion-skeleton-text :animated="true"></ion-skeleton-text>
      </ion-thumbnail>
      <ion-label>
        <h3>
          <ion-skeleton-text :animated="true" style="width: 80%;"></ion-skeleton-text>
        </h3>
        <p>
          <ion-skeleton-text :animated="true" style="width: 60%;"></ion-skeleton-text>
        </p>
        <p>
          <ion-skeleton-text :animated="true" style="width: 30%;"></ion-skeleton-text>
        </p>
      </ion-label>
    </ion-item>
  </ion-list>
</template>

<script setup lang="ts">
  import { IonItem, IonLabel, IonList, IonListHeader, IonSkeletonText, IonThumbnail } from '@ionic/vue';
</script>

<style scoped>
  ion-skeleton-text {
    --border-radius: 9999px;
    --background: rgba(188, 0, 255, 0.065);
    --background-rgb: 188, 0, 255;
  }
</style>
```

## Properties

### animated

**Description**: If `true`, the skeleton text will animate.

**Attribute**: `animated`

**Type**: `boolean`

**Default**: `false`

## Events

No events available for this component.

## Methods

No public methods available for this component.

## CSS Shadow Parts

No CSS shadow parts available for this component.

## CSS Custom Properties

| Name | Description |
| --- | --- |
| `--background` | Background of the skeleton text |
| `--background-rgb` | Background of the skeleton text in rgb format |
| `--border-radius` | Border radius of the skeleton text |

## Slots

No slots available for this component.
