Skip to content

Image

import { Image } from '@delightstack/components';
Hero landscape
View code
<script>
import { Image } from '@delightstack/components';
</script>
<Image src="/photos/hero.jpg" alt="Hero landscape" />

Prevent cumulative layout shift by setting a fixed aspect ratio.

Banner
View code
<Image src="/photos/banner.jpg" alt="Banner" aspect_ratio="16/9" />

Provide a tiny placeholder for a smooth blur-up transition as the full image loads. You can supply either a small placeholder image URL or a base64 ThumbHash via thumbhash (decoded internally — no extra network request). thumbhash takes precedence when both are set.

placeholder URL

thumbhash

View code
<!-- Tiny placeholder image URL -->
<Image
src="/photos/portrait.jpg"
alt="Portrait"
placeholder="/photos/portrait-thumb.jpg"
aspect_ratio="16/10"
/>
<!-- ThumbHash string (decoded to a blurred placeholder, no network cost) -->
<Image
src="/photos/dog.jpg"
alt="Dog"
thumbhash="1QcSHQRnh493V4dIh4eXh1h4kJUI"
aspect_ratio="16/10"
/>

Show a built-in broken-image icon or a custom fallback image when loading fails.

Missing
View code
<!-- Built-in fallback icon -->
<Image src="/missing.jpg" alt="Missing" fallback aspect_ratio="16/9" />
<!-- Custom fallback image -->
<Image src="/missing.jpg" alt="Missing" fallback="/fallback.png" aspect_ratio="16/9" />

Pass srcset and sizes for responsive image resolution switching.

<Image
src="/photos/landscape.jpg"
alt="Landscape"
srcset="/photos/landscape-400.jpg 400w, /photos/landscape-800.jpg 800w, /photos/landscape-1200.jpg 1200w"
sizes="(max-width: 600px) 400px, (max-width: 1000px) 800px, 1200px"
/>

Show a shimmer animation while the image loads (alternative to blur-up placeholder). Press Reload images to re-trigger the load and watch the shimmer.

Product
Product
View code
<Image src="/photos/product.jpg" alt="Product" skeleton aspect_ratio="1" />
PropTypeDefaultDescription
srcstringrequiredThe image source URL
altstringrequiredThe alt text for the image
widthnumberundefinedIntrinsic width in pixels
heightnumberundefinedIntrinsic height in pixels
aspect_ratiostringundefinedContainer aspect ratio (e.g. '16/9') to prevent CLS
fit'cover' | 'contain' | 'fill' | 'none''cover'How the image is scaled within its container
positionstring'center'The position of the image within its container (object-position)
lazybooleantrueWhether to lazily load the image
thumbhashstringundefinedBase64 ThumbHash decoded internally into a tiny blurred placeholder (takes precedence over placeholder, no network request)
placeholderstringundefinedA small placeholder image URL for blur-up effect
bg_colorstringundefinedSolid background colour painted before any image data arrives (great for SSR; avoids flash of empty box)
prioritybooleanfalseMark as above-the-fold — uses loading="eager" + fetchpriority="high"
fallbackstring | booleanfalseError fallback: true = built-in icon, string = fallback image URL
srcsetstringundefinedResponsive srcset attribute
sizesstringundefinedResponsive sizes attribute
skeletonbooleanfalseShow a skeleton shimmer while loading
idstringundefinedElement ID
classstring''Additional CSS classes
elementHTMLElementundefinedBindable reference to the root element ($bindable)
EventDetailDescription
onload{ natural_width: number, natural_height: number }Fires when the full image loads successfully
onerror{ error: Event }Fires when the image fails to load
  • Standard <img> element with required alt text
  • loading="lazy" attribute for native lazy loading (when lazy is true)
  • Placeholder image is marked aria-hidden="true" to avoid screen reader confusion
  • Fallback state shows a visual indicator without disrupting the accessibility tree
  • Smooth opacity transitions respect prefers-reduced-motion