Documentation / Affichage & médias
Skeleton
Un bloc de remplacement affiché pendant le chargement, à la forme du contenu attendu. Quatre formes (text, circular, rectangular, rounded), deux animations (pulse par défaut, wave) ou aucune (none).
width et height acceptent un nombre (en pixels) ou toute valeur CSS ; un circular qui n’a qu’une largeur reprend cette largeur en hauteur. count répète le bloc pour simuler plusieurs lignes. Chaque bloc porte aria-busy="true". Composant sans hook, compatible serveur.
Exemples
Lignes de texte
La forme text par défaut prend toute la largeur ; count en empile plusieurs.
import { Skeleton } from "@synertech/ui";
export function Basic() {
return (
<div className="max-w-md">
<Skeleton count={3} />
</div>
);
}Formes
variant adapte l’arrondi au contenu remplacé : avatar, image, carte.
import { Skeleton } from "@synertech/ui";
export function Variants() {
return (
<div className="flex items-center gap-4">
<Skeleton variant="circular" width={48} />
<Skeleton variant="rectangular" width={96} height={64} />
<Skeleton variant="rounded" width={96} height={64} />
<Skeleton variant="text" width="8rem" />
</div>
);
}Animations
wave fait défiler un reflet, none fige le bloc (utile si l’utilisateur réduit les animations).
import { Skeleton } from "@synertech/ui";
export function Animations() {
return (
<div className="max-w-md space-y-3">
<Skeleton animation="pulse" />
<Skeleton animation="wave" />
<Skeleton animation="none" />
</div>
);
}Carte en cours de chargement
On compose les formes pour reproduire la silhouette exacte du contenu final.
import { Skeleton } from "@synertech/ui";
export function CardPlaceholder() {
return (
<div className="flex max-w-sm gap-4 rounded-lg border border-gray-200 p-4 dark:border-gray-700">
<Skeleton variant="circular" width={48} />
<div className="flex-1 space-y-2">
<Skeleton width="60%" />
<Skeleton width="40%" height={12} />
<Skeleton variant="rounded" height={80} className="mt-3" />
</div>
</div>
);
}Remplacé par le contenu
Le squelette occupe la place du profil le temps de la requête, puis cède la place.
import { useEffect, useState } from "react";
import { Avatar, Skeleton } from "@synertech/ui";
export function WhileLoading() {
const [loading, setLoading] = useState(true);
useEffect(() => {
const timer = setTimeout(() => setLoading(false), 2000);
return () => clearTimeout(timer);
}, []);
return (
<div className="flex items-center gap-3">
{loading ? (
<Skeleton variant="circular" width={40} />
) : (
<Avatar fallback="CD" alt="Camille Durand" />
)}
{loading ? (
<Skeleton width={140} />
) : (
<span className="text-sm font-medium text-gray-900 dark:text-gray-100">Camille Durand</span>
)}
</div>
);
}Référence d’API
Composants
import { Skeleton } from "@synertech/ui";Props — SkeletonProps
| Prop | Type | Défaut | Description |
|---|---|---|---|
animation |
SkeletonAnimation |
"pulse" |
|
count |
number |
1 |
|
height |
string | number |
— | |
variant |
SkeletonVariant |
"text" |
|
width |
string | number |
— |
+ 279 attributs natifs hérités de HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, gestionnaires d’événements…).
Types
type SkeletonAnimation = "pulse" | "wave" | "none"SkeletonVariant
Typetype SkeletonVariant = "text" | "circular" | "rectangular" | "rounded"