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
Prop | Type | Default | Description |
---|---|---|---|
$aspectRatio | string | 1 / 1 | The aspect ratio prop can be changed to set the aspect ratio of the main image container. |
$navigation | boolean | true | 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. |
$size | string | small | 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. |
$thumbnailRailPlacement | string | bottom | The placement of the thumbnail rail. This prop is responsive and shows a preview of the other images within the gallery |
$expand | boolean | false | Icon Button to maximise the main image, opening it as an overlay. It will be applied to all of the items in the gallery. |
$thumbnailOutline | boolean | false | An outline to thumbnails that provides contrast against the background the gallery is used on. |
ProductGallery.Item
Prop | Type | Default | Description |
---|---|---|---|
$expand | boolean | false | Icon Button to maximise the main image, opening it as an overlay. It will be applied only to item that is specified in. |
thumbnailSrc | string | - | Sets the image source for the thumbnail of the specified item. This prop takes precedence over the child element passed into the item. |
thumbnailAlt | string | - | 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.
$thumbnailRailPlacement
The $thumbnailRailPlacement
prop can be set to bottom
(default) or side
.
$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.
Callbacks
onMount
The onMount
callback will return an array
containing ref
s 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.
Video in Gallery
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:
Translation | Description |
---|---|
product-gallery.expandControls.label | aria-label for the expand control item |
product-gallery.navigation.next | descriptive text for the next item action |
product-gallery.navigation.previous | descriptive text for the previous item action |
For more on translatable fields, view the useTranslation
docs here: useTranslation