Skeleton
<pc-skeleton> Skeletons are used to provide a visual representation of where content will eventually be shown.
These are simple containers for scaffolding layouts that mimic what users will see when content has finished loading. This prevents large areas of empty space during asynchronous operations.
This component is trying to not be opinionated, as there are endless possibilities for designing layouts. Therefore, you’ll likely use more than one skeleton to create the effect you want. If you find yourself using them frequently, consider creating a template that renders them with the desired arrangement and styles.
<div class="skeleton-overview">
<header>
<pc-skeleton effect="sheen"></pc-skeleton>
<pc-skeleton effect="sheen"></pc-skeleton>
</header>
<pc-skeleton effect="sheen"></pc-skeleton>
<pc-skeleton effect="sheen"></pc-skeleton>
<pc-skeleton effect="sheen"></pc-skeleton>
</div>
<style>
.skeleton-overview header {
display: flex;
align-items: center;
margin-block-end: var(--pc-spacing-m);
}
.skeleton-overview header pc-skeleton:first-child {
float: left;
margin-inline-end: var(--pc-spacing-l);
inline-size: 3rem;
block-size: 3rem;
vertical-align: middle;
}
.skeleton-overview header pc-skeleton:last-child {
flex: 0 0 auto;
inline-size: 30%;
}
.skeleton-overview pc-skeleton {
margin-block-end: var(--pc-spacing-l);
}
.skeleton-overview pc-skeleton:nth-child(3) {
inline-size: 95%;
}
.skeleton-overview pc-skeleton:nth-child(4) {
inline-size: 80%;
}
</style> There are two built‐in effects, sheen and pulse. The effects are intentionally subtle, as they can be distracting when used extensively. The default is none which displays a static non‐animated skeleton.
Use multiple skeletons and some CSS styles to simulate paragraphs.
Set a matching width and height to make a circle, square or rounded avatar skeleton.
Set a border-radius on the indicator part to make circles, squares and rectangles. For more complex shapes, you can apply clip-path to the indicator part.
Change the --color and --sheen-color custom properties to adjust the colours of the skeleton.
| Name | Description | Reflects | Default |
|---|---|---|---|
effect | Determines the effect the skeleton will use. Type: "pulse" | "sheen" | "none" |
| "none" |
updateComplete | A read‐only promise that resolves when the component has finished updating. | ‐ |
Learn more about customising animations.
| Name | Description | Default |
|---|---|---|
--color | The colour of the skeleton. | var(--pc-color-neutral-fill-normal) |
--sheen-color | The sheen colour of the skeleton. | color-mix(in oklab, var(--color), var(--pc-color-surface-raised) 40%) |
Learn more about customising custom properties.
| Name | Description |
|---|---|
indicator | The skeleton’s indicator. |
Learn more about customising CSS parts.
If you’re using the autoloader or the standard loader, you can skip this section. But if you’re cherry picking, you can use any of the following snippets to import this component.
To manually import this component from the CDN, copy this code snippet and paste it in your HTML.
<script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.4/cdn/components/skeleton/skeleton.js"></script> To manually import this component from the CDN, copy this code snippet and paste it in your JavaScript file.
import "https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.4/cdn/components/skeleton/skeleton.js"; To manually import this component from npm, copy this code snippet and paste it in your JavaScript file.
import "placer-toolkit/dist/components/skeleton/skeleton.js";