Product Image

Installation

  yarn add @chewy/kib-product-styles

Import

  @use '~@chewy/kib-product-styles/src/kib-product-image/styles' as kib-product-image;

Mixins

image-container

@mixin image-container() { ... }@mixin image-container() { 
  position: relative;
  display: block;
  width: 100%;

  // At the moment, the product card can only handle square images and as
  // the cards width goes up and down, the image height scales accordingly to maintain
  // the 1:1 square ratio. In the case that wider product cards want to be explored
  // but image height maxed out then adjust max-width;
  max-width: var(--kib-product-image-max-width, #{settings.$max-width});

  &::after {
    display: block;
    padding-top: 100%;
    content: '';
  }
 }
Description

Root image styles

Parameters

None.

Requires

image

@mixin image() { ... }@mixin image() { 
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: translate(-50%, -50%);
 }
Description

Image element styles

Parameters

None.

Variables

max-width

$max-width: unit.rem(248px) !default;
Description

Max width of image

Type

Number