Return to Sky UI homepage
import { Image } from '@sky-uk/ui-core';

The Image is just a styled HTML image and supports any natively supported attributes such as src, srcSet and sizes.

Props

Focal Point

You can specify a focal point for the image by passing x and y coordinates to the focalPoint prop. This will apply the object-fit:cover styles automatically.

$focalPoint supports values 0 - 24 and any values outside of that range will be capped.

System Modifiers

The Image component supports the props applied using the following system modifiers:

Responsive Images

There are a few methods of creating responsive images depending on the desired outcome.

srcSet

We can use srcSet to provide the browser with multiple scaled versions of an asset, this gives the browser autonomy on which image to use based on screensize and bandwidth etc.

Visit MDN srcSet docs for more information.

The browser will always use the largest cached image rather than explicity requesting version for smaller sizes so this should not be used when you wish to show specific images at different sizes.

picture

The picture element allows you to specify multiple source elements. Each source can have it's own srcSet along with media queries to specific when to show each.

Visit MDN picture docs for more information.

The browser will always load the source with matching media query, if you don't need to show different tailored images at different breakpoints then consider srcSet as it's unlikely to result in as many requests if the browser is resized.

Accessibility

It's vital that we ensure our images have the correct markup to make them accessible to all users. See our guide for creating inclusive images for more information.