Return to Sky UI homepage

Product Gallery - React

import { ProductGallery } from '@sky-uk/ui-core';

The Product Gallery component is used to visually showcase the features of a product

Props

ProductGallery

PropTypeDefaultDescription
$aspectRatiostring1 / 1

The aspect ratio prop can be changed to set the aspect ratio of the main image container.

$navigationbooleantrue

Icon Buttons to allow navigation to the previous or next gallery item. It will be applied to all of the items in the gallery. This is a responsive prop.

$sizestringsmall

Sets the size variant of the Product Gallery. This prop is responsive and can be used to set the size of the Product Gallery at different breakpoints.

$thumbnailRailPlacementstringbottom

The placement of the thumbnail rail. This prop is responsive and shows a preview of the other images within the gallery

$expandbooleanfalse

Icon Button to maximise the main image, opening it as an overlay. It will be applied to all of the items in the gallery.

$thumbnailOutlinebooleanfalse

An outline to thumbnails that provides contrast against the background the gallery is used on.

ProductGallery.Item

PropTypeDefaultDescription
$expandbooleanfalse

Icon Button to maximise the main image, opening it as an overlay. It will be applied only to item that is specified in.

thumbnailSrcstring-

Sets the image source for the thumbnail of the specified item. This prop takes precedence over the child element passed into the item.

thumbnailAltstring-Sets the image alt text for the thumbnail image set by the thumbnailSrc.

$size

The $size prop can be set to small (default) or large depending on the viewport size.

Please view this example in fullscreen mode. Click the full screen button above.

$thumbnailRailPlacement

The $thumbnailRailPlacement prop can be set to bottom (default) or side.

Please view this example in fullscreen mode. Click the full screen button above.

$expand

$expand is a boolean property that when passed in to ProductGallery renders expand controls on all items within the gallery. This property can also be set on individual ProductGallery.Item components if expand controls are only required for specific items. $expand set on the ProductGallery will take precedence.

Note: The $expand prop only adds the expand icon button to the component. The expand functionality itself must be implemented using the onExpandControl callback as documented below.

Variant Usage

To adhere to the variant governance set in usage, avoid using $size="large" and $thumbnailRailPlacement="side" in the ProductGallery component on small screens (e.g., mobile). This combination may negatively impact usability and layout. Instead, choose a configuration better suited for smaller viewports.

Please view this example in fullscreen mode. Click the full screen button above.

Callbacks

onMount

The onMount callback will return an array containing refs to all the items. This can be used to manage the state of the slides.

onItemChange

The onItemChange callback returns an object representing the current item once the transition is complete. The current key is the 0 indexed current item as a number. The ref key is a ref to the current item.

onExpandControl

The onExpandControl callback will return the state of the expand control as an object when any of the expand control state changes. Management of the expand property is the concern of the consumer.

When using a video inside ProductGallery, we recommend using the native media controls to ensure a consistent playback experience across devices. Below are two examples of possible implementations of video in the component.

Note: To prevent multiple videos from playing simultaneously, ensure that the currently active video is paused when switching to another item in the gallery.

System Modifiers

The ProductGallery component also accepts props applied using the following system modifiers:

Translatable Fields

The Product Gallery support translation on the following fields:

TranslationDescription
product-gallery.expandControls.labelaria-label for the expand control item
product-gallery.navigation.nextdescriptive text for the next item action
product-gallery.navigation.previousdescriptive text for the previous item action

For more on translatable fields, view the useTranslation docs here: useTranslation