Image

Utility component can be used to display an image and control its size and shape.

Import

import { Image } from '@vortex-kit/vortex';
import type { ImageProps } from '@vortex-kit/vortex';

Display

<Image src='/image.webp' alt='Image' />

Allied components

Image
Features
Supports different sizes and shapes.
Allows different objectFit options.
Has fallback content support.
Accessibility features.
Reference Links
WAI

Display

Use the objectFit prop to control how the image is displayed. By default, the image display mode is cover.

Loading...

Show Code

ObjectFit with Different Sizes

Use objectFit with different sizing approaches for optimal display.

Loading...

Show Code

Radius

Use the borderRadius prop to control the border radius of the image. Available values: 2xs, xs, sm, md, lg, xl.

Loading...

Show Code

Aspect Ratio

Additionally, you can control the image size by wrapping the image in a Stack component and setting the aspectRatio prop.

Loading...

Show Code

Fallback

When the image fails to load, you can use the fallback prop to display a fallback for the image. The fallback can be another image URL, a React component, or a boolean value.

Loading...

Show Code

Size

Use the width and height props to control the size of the image.

Loading...

Show Code

Responsive Sizing

Use responsive sizing with breakpoint objects for different screen sizes.

Loading...

Show Code

Image Optimization

This component uses the <img /> tag under the hood. If you are using Next.js or Gatsby, you can leverage the next/image or gatsby-image component to optimize the image loading.

The primary advantage of using this component is that it provides an additional API to control the image size and shape, including properties like borderRadius, objectFit, fallback, and etc. The imageSlot prop allows you to customize how the image is rendered, enabling you to pass in specific attributes for the underlying image component.

Loading...

Show Code

Accessibility

It is required to utilize the alt prop ensuring that a meaningful description is provided for users relying on screen readers. In cases where the alt attribute is omitted, the image will be considered decorative and will adopt the presentation role.

Key
Description
The alt prop provides a meaningful description of the image, enhancing accessibility for screen readers.
Image Utility — Vortex Design System