Media image styling reference
On this page
A media image is a picture of a product or another record, in the box a screen gives it, or a placeholder with a faint icon when there is no picture. Follow the POS styling API rules when styling it.
Where it appears
The image on a product card and an action tile, the thumbnail on a cart row and on an order’s items, the pictures in a list item and the variants menu, the stack of thumbnails a bundle shows, and the gallery on a product’s screen.
A screen sizes and shapes the image for where it sits, with the size, shape, corners, and
shadow set around the image, so a property set on :root doesn’t reach those images. A
property set on media-image-root does, everywhere. The width and height reach an image only
from a rule for the image itself, so set on :root or around an image they reach none. The
card and the cart item card also publish properties for the image inside them,
--sc-card-image-* and --sc-cart-item-card-media-*, which change only those.
Parts
| Part | What it is | Available from |
|---|---|---|
media-image-root |
The whole image: the box with the corners, border, and shadow, holding the picture or the placeholder. | v22.0.13 |
media-image-picture |
The picture itself, when there is one. | v22.0.13 |
media-image-placeholder |
The box drawn in place of a picture when there is none, with a faint icon in it. | v22.0.13 |
The Available from column shows the first release that carries the name.
Component properties
Set these on media-image-root to change every image.
| Property | What it sets | Default | Available from |
|---|---|---|---|
--sc-media-image-size |
The width and height of the image, in place of the size the screen gives it. | none | v22.0.13 |
--sc-media-image-width |
The width of the image alone, in place of the size, or auto to let the shape decide it. It applies only when set on the image itself. | none | v22.0.13 |
--sc-media-image-height |
The height of the image alone, in place of the size, or auto to let the shape decide it. It applies only when set on the image itself. | none | v22.0.13 |
--sc-media-image-default-size |
The size of an image nothing else sizes. The POS sets it on each image it gives a size, so it reaches only the rest. | none | v22.0.13 |
--sc-media-image-aspect-ratio |
The shape of the image, as width / height, on the side the size leaves free. | none | v22.0.13 |
--sc-media-image-object-fit |
How the picture fills the image, such as cover to crop it or contain to show all of it. | cover | v22.0.13 |
--sc-media-image-radius |
The corners of the image and the placeholder. | 8px | v22.0.13 |
--sc-media-image-border |
A border around the image, as a border shorthand. | none | v22.0.13 |
--sc-media-image-shadow |
The shadow under the image, as a box shadow. | none | v22.0.13 |
--sc-media-image-placeholder-bg |
The fill of the placeholder. It falls back to the raised surface color. | none | v22.0.13 |
Examples
Each example is tested against the POS on every change.
“Round the images less.”
```css
[part~=’media-image-root’] { –sc-media-image-radius: 4px; } ```
“Show all of each picture instead of cropping it.”
```css
[part~=’media-image-root’] { –sc-media-image-object-fit: contain; } ```
“Give the placeholders a white fill.”
```css
[part~=’media-image-root’] { –sc-media-image-placeholder-bg: #ffffff; } ```
“Draw a thin border around every image.”
```css
[part~=’media-image-root’] { –sc-media-image-border: 1px solid #d0d5dd; } ```
“Show the pictures in black and white.”
```css
[part~=’media-image-picture’] { filter: grayscale(1); } ```
What can’t be styled yet
- A muted, disabled, or loading image, which has no attribute to tell it apart yet
- The dashed border a media group draws around an expired image, and the way a media group stacks the images
- The default size of an image the POS gives a size, which the POS sets on the image itself: set
--sc-media-image-sizeinstead - The size a screen gives an image, which a property set on
:rootdoesn’t reach: set it onmedia-image-root, or on the card’s or the cart row’s own property
Retired
None yet.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.