0.6.13

Image

Source code
Default
Local Image

Usage

---
import { Image } from '@yatoday/astro-ui/astro';
import myImage from '~/assets/images/800x800.svg';
---

<!-- Default -->
<Image src="~/assets/images/800x800.svg" alt="Local Image" />

<!-- Imported image -->
<Image src={myImage} alt="Local Image" />

<!-- With props -->
<Image
  src={src}
  class="w-full md:h-full bg-gray-400 dark:bg-slate-700"
  widths={[400, 900]}
  width={400}
  sizes="(max-width: 900px) 400px, 900px"
  alt={title}
  aspectRatio="16:9"
  layout="cover"
  loading="lazy"
  decoding="async"
/>

Props

PropTypeDefaultDescription
srcstring-Specifies the path to the image
widthnumberdefaultSpecifies the width of an image (px)
heightstring-Specifies the height of an image
altstring-Specifies an alternate text for an image
loadingeager | lazyeagerSpecifies whether a browser should load an image immediately or to defer loading of images until some conditions are met
decodingsync | async | autosyncWhether it should wait for the image to be decoded before presenting other content updates or not. Read more
sizesstring-Specifies image sizes for different page layouts
widthsstring--
aspectRatiostring--
objectPositionstring--
formatstring--
layoutconstrained | fixed | fullWidthconstrainedImage size relative to container

layout

Helper attribute for setting image size