Media gallery styling reference
On this page
A media gallery shows a record’s images one at a time, such as the pictures on a product’s page. Operators swipe the frame to move between images, or tap a thumbnail to pick one. You can change the size, shape, corners, and shadow of the media gallery frame, the size and border of the thumbnails, etc. Follow the POS styling API rules when you style media galleries.
Where a media gallery appears
Media galleries appear in these places:
- On a product’s page and in the bundle dialog. When the product has more than one image, the media gallery has a row of thumbnails under the frame, and previous and next buttons on the frame. In the bundle dialog, the frame has a shadow.
- On a product card with more than one image, in place of the card’s image. Operators swipe the image, and there are no dots or buttons. The frame is 1.3 / 1 here, inside the card’s
card-imagepart, so the card image properties set the shape of each image.
No screen shows the media gallery dots yet. Media galleries on a product’s page and in the bundle dialog show thumbnails instead, and media galleries on product cards have no dots.
Each image in a media gallery frame and in the thumbnails is a media image. The media gallery sets the size and corners of these images, and the fit of the image in the frame, so media image properties for these set on :root do not change them. A fit set on :root does change the thumbnails. To change the images in media galleries only, set the properties on media-gallery-frame or media-gallery-thumbnail.
On a product’s page and in the bundle dialog, the screen sets the corners of the frame and, on a small screen, the maximum height of the frame. --sc-media-gallery-radius and --sc-media-gallery-max-height set on :root do not change these, so set them on media-gallery-root instead.
The swipe track inside a media gallery frame is a pager, so a rule for pager-root styles it along with every other pager.
Parts
| Part | What it is | Available from |
|---|---|---|
media-gallery-root |
The whole gallery: the image showing and, under it, the strip of thumbnails when the screen shows one. | v22.0.19 |
media-gallery-frame |
The box the image showing fills, with the corners and shadow, which operators swipe to see the next image. Each image in it is a media image. | v22.0.19 |
media-gallery-previous-button |
The button on the frame that shows the image before, which appears while the pointer is over a gallery of more than one image. It is a button, so the button properties apply to it. | v22.0.19 |
media-gallery-next-button |
The button on the frame that shows the image after, which appears while the pointer is over a gallery of more than one image. It is a button, so the button properties apply to it. | v22.0.19 |
media-gallery-indicator |
The row of dots at the foot of the frame, one for each image, on a gallery of more than one image without thumbnails. Not used on any screen yet. | v22.0.19 |
media-gallery-dot |
One dot, standing for one image. Not used on any screen yet. | v22.0.19 |
media-gallery-thumbnails |
The strip of thumbnails under the frame, on a gallery of more than one image whose screen shows them. | v22.0.19 |
media-gallery-thumbnail |
One thumbnail, which shows the thumbnail’s image in the frame when pressed. The image in it is a media image. | v22.0.19 |
The Available from column shows the first release that carries the name.
Attributes
Narrow media-gallery-dot or media-gallery-thumbnail by these, inside :where(), to style the
one for the image showing.
| Attribute | Values | Default | Available from |
|---|---|---|---|
media-gallery-dot[data-active] |
true, false |
false |
v22.0.19 |
media-gallery-thumbnail[aria-current] |
true, false |
false |
v22.0.19 |
Component properties
Set these on media-gallery-root or on :root.
| Property | What it sets | Default | Available from |
|---|---|---|---|
--sc-media-gallery-max-width |
The widest the gallery gets. | 400px | v22.0.19 |
--sc-media-gallery-max-height |
The tallest the image showing gets. The gallery narrows to keep the screen’s shape for the frame, so the frame doesn’t grow past it unless you also set --sc-media-gallery-aspect-ratio. |
100vh | v22.0.19 |
--sc-media-gallery-aspect-ratio |
The shape of the frame, as width / height, in place of the screen’s: 1/1, or 1.3 / 1 on a product card. | 1/1 | v22.0.19 |
--sc-media-gallery-radius |
The corners of the frame. | unset | v22.0.19 |
--sc-media-gallery-shadow |
The shadow around the frame, as a box shadow. | none | v22.0.19 |
--sc-media-gallery-gap |
The space between the frame and the strip of thumbnails. | var(–sc-spacing-3) | v22.0.19 |
--sc-media-gallery-nav-indicator-size |
The width and height of each dot. Not used on any screen yet. | 8px | v22.0.19 |
--sc-media-gallery-thumbnail-size |
The width and height of each thumbnail. | 56px | v22.0.19 |
--sc-media-gallery-thumbnail-border |
The border around each thumbnail. | 1px solid rgb(var(–sc-color-layer-dark) / 12%) | v22.0.19 |
Examples
Each example is tested against the POS on every change.
“Round the gallery’s corners and drop the shadow.”
```css
[part~=’media-gallery-root’] { –sc-media-gallery-radius: 12px; –sc-media-gallery-shadow: none; } ```
“Keep the gallery narrower.”
```css
[part~=’media-gallery-root’] { –sc-media-gallery-max-width: 280px; } ```
“Make the thumbnails bigger, with a lighter border.”
```css
[part~=’media-gallery-root’] { –sc-media-gallery-thumbnail-size: 72px; –sc-media-gallery-thumbnail-border: 1px solid #e0e0e0; } ```
“Ring the thumbnail of the image showing in our brand color.”
```css
outline-color: #0b5394; } ```
“Show the dot for the image showing in full.”
```css
opacity: 1; } ```
“Make the previous and next buttons our brand color.” They are buttons, so set the button properties:
```css
[part~=’media-gallery-previous-button’], [part~=’media-gallery-next-button’] { –sc-button-bg: #0b5394; –sc-button-color: #ffffff; } ```
“Take the background off the strip of thumbnails.”
```css
[part~=’media-gallery-thumbnails’] { background-color: transparent; } ```
What can’t be styled yet
- The gallery on a product card apart from the one on a product’s page or the bundle’s dialog, since no screen gives it a name yet
- The swipe track inside the frame alone, apart from every other pager
- How the previous and next buttons slide in while the pointer is over the gallery
- Where the previous and next buttons sit on the frame, and where the dots sit
- The height cap’s arithmetic when you set the frame’s shape: the gallery works out the narrowing from the screen’s shape, not yours
Retired
None yet.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.