Image

An image component with built-in support for aspect ratio, object-fit, and border radius options.

Anatomy

<script>
  import { Image } from "@saas-ui/svelte/components/image";
</script>

<Image
  src="https://example.com/image.jpg"
  alt="Description"
  width="300"
  height="200"
  rounded="md"
  fit="cover"
  aspectRatio="16/9"
/>

Examples

Aspect Ratio Accessibility

Image with a specific aspectRatio.

Basic Accessibility

Basic image with default styling.

Circular Accessibility

Circular image using rounded="full".

Height Accessibility

Image with a fixed height.

Object Fit Accessibility

Different fit options.

Rounded Accessibility

Different rounded options.

Props

Prop Type Default Description
src text - The image source URL.
alt text - Alternative text for the image.
width text - The width of the image (CSS value or number for pixels).
height text - The height of the image (CSS value or number for pixels).
aspectRatio text - The aspect ratio of the image (e.g., 16/9, 4/3, 1).
rounded none | sm | md | lg | xl | 2xl | 3xl | full none The border radius of the image.
fit contain | cover | fill | none | scale-down cover The object-fit property of the image.
class text - Additional CSS classes to apply.