Image
Encapsule <img> avec les garanties qu'il n'impose pas par défaut : espace réservé (anti-CLS), lazy loading, support WebP, états de chargement et d'erreur. Wraps <img> with the guarantees it doesn't enforce by default: reserved space (anti-CLS), lazy loading, WebP support, loading and error states.
DémonstrationDemo
Par défaut — lazy, sans skeletonDefault — lazy, no skeleton
object-fit: cover / containobject-fit: cover / contain
État d'erreur — repli si l'image échoueError state — fallback on failed load
Règles absoluesAbsolute rules
-
widthetheightobligatoires — sinon le CLS que le composant existe pour éviter se produit quand mêmewidthandheightare required — otherwise the CLS this component exists to prevent still occurs -
altobligatoire saufdecorative— WCAG 1.1.1altrequired unlessdecorative— WCAG 1.1.1 -
prioritysur une seule image par page (la véritable LCP)priorityon at most one image per page (the true LCP) -
skeletonpar défaut sur chaque petite image inline — réservé aux images lourdes/heroskeletonby default on every small inline image — reserved for heavy/hero images
Tokens de composantComponent tokens
| Token CSS | RéférenceReference | ValeurValue |
|---|---|---|
--agtc-component-image-skeleton-background | semantic.color.background.subtle | #f0f0f0 |
--agtc-component-image-skeleton-background-pulse | semantic.color.background.hover | #fafafa |
--agtc-component-image-fallback-background | semantic.color.background.subtle | #f0f0f0 |
--agtc-component-image-fallback-icon | semantic.color.text.secondary | #646464 |
--agtc-component-image-fallback-text | semantic.color.text.secondary | #646464 |
AccessibilitéAccessibility
altmanquant sansdecorative: avertissement console (WCAG 1.1.1)Missingaltwithoutdecorative: console warning (WCAG 1.1.1)- Image décorative :
alt=""+aria-hidden="true"Decorative image:alt=""+aria-hidden="true" - État de repli :
role="img"+aria-labelreprenant le texte alternatifFallback state:role="img"+aria-labelcarrying the same alt text - Animation du skeleton désactivée sous
prefers-reduced-motionSkeleton animation disabled underprefers-reduced-motion
ImplémentationImplementation
<!-- De base — width/height obligatoiresBasic — width/height required -->
<agtc-image src="photo.jpg" alt="…" width="800" height="450"></agtc-image>
<!-- WebP avec repliwith fallback -->
<agtc-image src="photo.jpg" src-webp="photo.webp" alt="…" width="800" height="450"></agtc-image>
<!-- Skeleton en option (images lourdes/hero)Opt-in skeleton (heavy/hero images) -->
<agtc-image src="hero.jpg" alt="…" width="1200" height="630" skeleton></agtc-image>
<!-- LCP -->
<agtc-image src="hero.jpg" alt="…" width="1200" height="630" priority></agtc-image>
DOs et DON'TsDOs and DON'Ts
À faireDo
- Toujours fournir
widthetheightAlways providewidthandheight - Réserver
priorityà la véritable image LCPReservepriorityfor the true LCP image - Utiliser
skeletonpour les images lourdes/hero seulementUseskeletonfor heavy/hero images only
À éviterDon't
- Omettre
width/heightOmittingwidth/height decorativesur une image porteuse de sensdecorativeon a meaningful imageprioritysur plus d'une image par pagepriorityon more than one image per page
UX Patterns Reference
Patterns approved via the
ux-pattern-reviewworkflow (ADR-036). Decision: all approved, skeleton explicitly requested for v1.
| Pattern | Source | Applied | Justification |
|---|---|---|---|
| Decorative vs meaningful image distinction | WCAG 1.1.1 / NN/g | ✅ | Mirrors the pattern already approved on agtc-icon — decorative prop → alt="" + aria-hidden |
| Skeleton screen while loading (opt-in) | NN/g — Skeleton Screens 101 | ✅ | Included in v1 per explicit human decision (2026-07-21) — opt-in via skeleton, not on by default, since it's overkill for small inline images |
| Graceful fallback on load failure | General error-handling principle (no dedicated reference-source article found for images specifically) | ✅ | Icon + visible alt text instead of a broken-image hole |
object-fit configurable | Design system decision (not a reference-source pattern) | ✅ | fit prop, default cover — consistent cropping across avatar/illustration usages |