Skip to content

Image

Any ratio other than natural fills the width and crops with object-fit: cover. Pass an imported image to get Astro’s optimised srcset, or a URL string for a plain img.

Placeholder for a screenshot
  • src: an imported image or a URL string (required)
  • alt: alternative text (required; use "" for decorative images)
  • ratio: natural (default), square (1:1), portrait (4:5), landscape (4:3), wide (16:9), cinema (21:9)
  • loading: default "lazy"; decoding: default "async"
  • Imported images only: format (default "webp"), quality (default 85), widths, layout (default "constrained")
  • Any other img attribute is passed through
---
import Image from "@samla/ui/Image.astro";
import screen from "../assets/demo-site.png";
---
<Image src={screen} alt="The demo site in a browser" ratio="wide" />
All ratios
natural
square
portrait
landscape
wide
cinema