Skip to content

    Image

    An image that never shows an empty box or pops in. The frame keeps its size from ratio, a small blurred version of the picture shows at once, and the full image fades in over it once it has loaded.

    React

    Preview

    Waves breaking against coastal rocks at dusk

    Props

    • ratio
    • radius
    • loaded
    • blurred
    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="16:9" className="w-80 min-w-0 max-w-full" />

    Usage

    When to use

    • Show a photo, cover or illustration whose space must be kept while it loads.
    • Show a blurred version of the picture first and fade to the full image once it loads.

    When not to use

    • A person, team or workspace picture. Use Avatar.
    • Content whose layout is known but whose data is still loading. Use Skeleton.

    Platform support

    What each platform has, from the spec. A selected platform is highlighted.

    NameWebiOSAndroidNote
    srcYesDeferredDeferredNot generated for iOS and Android.
    altYesYesYes
    placeholderSrcYesDeferredDeferredNot generated for iOS and Android.
    ratioYesYesYes
    radiusYesYesYes
    placeholderNoYesYesOnly on iOS, Android.

    Variants

    ratio

    Width to height of the frame: 1:1, 4:3, 3:2, 16:9 or 21:9. Reserves the space before anything loads, so nothing moves. On web you can also pass a custom CSS aspect-ratio or set a height with className.

    • Waves breaking against coastal rocks at dusk

      1:1

    • Waves breaking against coastal rocks at dusk

      4:3

    • Waves breaking against coastal rocks at dusk

      3:2

    • Waves breaking against coastal rocks at dusk

      16:9default

    • Waves breaking against coastal rocks at dusk

      21:9

    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <Image ratio="1:1" src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} className="w-80 min-w-0 max-w-full" />
    <Image ratio="4:3" src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} className="w-80 min-w-0 max-w-full" />
    <Image ratio="3:2" src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} className="w-80 min-w-0 max-w-full" />
    <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="16:9" className="w-80 min-w-0 max-w-full" />
    <Image ratio="21:9" src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} className="w-80 min-w-0 max-w-full" />

    radius

    Corner radius of the frame: auto follows the theme's radius-container token; full clips to a pill or circle (radius-full).

    • Waves breaking against coastal rocks at dusk

      autodefault

    • Waves breaking against coastal rocks at dusk

      full

    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="16:9" className="w-80 min-w-0 max-w-full" />
    <Image radius="full" src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="16:9" className="w-80 min-w-0 max-w-full" />

    Examples

    A cover image

    The blurred copy shows at once, and the full image fades in over it.

    Waves breaking against coastal rocks at dusk
    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="16:9" className="w-80 min-w-0 max-w-full" />

    Aspect ratios

    Standard ratios keep the frame size before the image loads.

    Waves breaking against coastal rocks at duskWaves breaking against coastal rocks at duskWaves breaking against coastal rocks at duskWaves breaking against coastal rocks at dusk
    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <div className="flex flex-wrap items-start gap-md">
      <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="1:1" className="w-32 min-w-0 max-w-full" />
      <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="4:3" className="w-40 min-w-0 max-w-full" />
      <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="3:2" className="w-44 min-w-0 max-w-full" />
      <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="21:9" className="w-64 min-w-0 max-w-full" />
    </div>

    Round corners

    auto follows the theme radius; full clips to a pill or circle.

    Waves breaking against coastal rocks at dusk
    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <Image src={photo.src} placeholderSrc={photo.placeholder} alt={photo.alt} ratio="1:1" radius="full" className="w-40 min-w-0 max-w-full" />

    Still loading

    Without src yet, the blurred copy holds the frame.

    import { Image } from "@/components/ui/image"
    
    const photo = {
      src: "/preview/image.webp",
      placeholder: "data:image/webp;base64,UklGRlQAAABXRUJQVlA4IEgAAAAQAgCdASoQAAkAA4BaJYwCdAEUqmjrjVQAAP38+YDmf9Eo/Ca357fO1AWFdDm2ty8mQaRq1ONOedvyWep0rXs8n8nHwpa4AAA=",
      alt: "Waves breaking against coastal rocks at dusk"
    }
    
    <Image placeholderSrc={photo.placeholder} alt={photo.alt} ratio="16:9" className="w-80 min-w-0 max-w-full" />

    Do and don't

    Do

    • Always reserve the space: ratio, an aspect class or a fixed height.
    • Make placeholderSrc when the image is added, at build time or on upload, and inline it as a data URL.
    • Serve the full image at the size it is shown (srcSet and sizes pass through to the image).

    Don't

    • Don't load placeholderSrc from a URL of its own: it would need a placeholder too.
    • Don't use it for an avatar. Use Avatar, which shows initials until the photo loads.
    • Don't put text over the image; its contrast is not checked.

    Props

    NameTypeValuesDefaultDescription
    srcstring--The full image. Until it is set and has loaded, the blurred copy (or the gray frame) shows. A new src shows the blurred copy again until the new image loads. Not generated for iOS and Android.
    alt requiredstring--What the image shows, for screen readers. "" for a decorative image.
    placeholderSrcstring--A small blurred version of the same image, best an inline data URL of a few hundred bytes (16 by 9 pixels is enough), made when the image is added (at build time or on upload), so it shows with the page and needs no request. Without it the frame shows the soft gray fill. Not generated for iOS and Android.
    ratioenum1:1 | 4:3 | 3:2 | 16:9 | 21:916:9Width to height of the frame: 1:1, 4:3, 3:2, 16:9 or 21:9. Reserves the space before anything loads, so nothing moves. On web you can also pass a custom CSS aspect-ratio or set a height with className.
    radiusenumauto | fullautoCorner radius of the frame: auto follows the theme's radius-container token; full clips to a pill or circle (radius-full).
    placeholdernode--Native only: a blurred placeholder view shown behind the image while it loads. Only on iOS, Android.

    Slots

    NameRequiredDescription
    imageyesNative only: the image view you supply, drawn over the gray frame and clipped to the ratio and radius.

    Anatomy

    PartDescription
    rootThe frame: element corners, the soft gray fill, clips what is inside. ratio sets its aspect ratio, so the space is kept before anything loads.
    blurredplaceholderSrc: a few pixels of the same picture, scaled to the frame and blurred, shown at once.
    imageThe full image on top. Transparent until it has loaded, then it fades in with duration-medium.

    Accessibility

    Role: img

    • alt is required by the type. Describe what the image shows; pass alt="" only for a decorative image.
    • The blurred copy is hidden from screen readers (alt="" and aria-hidden), so the image is read once.
    • No fade under prefers-reduced-motion: the full image appears in one step.
    • A failed image shows the browser's broken-image box with the alt text, not an endless placeholder.

    Install

    npx werewolf-ui add image

    Run npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.