Product Card

Installation

  yarn add @chewy/kib-product-styles

Import

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

Mixins

card

@mixin card() { ... }@mixin card() { 
  @include kib-foundations.card;

  position: relative;
  display: flex;
  flex-direction: column;
  max-width: var(--kib-product-card-max-width, #{settings.$max-width});
  min-width: var(--kib-product-card-min-width, #{settings.$min-width});
 }
Description

Root product card including landscape styles

Parameters

None.

Requires

card-elevated

@mixin card-elevated() { ... }@mixin card-elevated() { 
  @include elevation.apply('emphasis-secondary');
 }
Description

Elevated variant styles

Parameters

None.

card-flat

@mixin card-flat() { ... }@mixin card-flat() { 
  border: none;
 }
Description

Flat variant styles

Parameters

None.

card-landscape

@mixin card-landscape() { ... }@mixin card-landscape() { 
  display: grid;
  grid-auto-columns: #{settings.$landscape-grid-base-settings};

  --kib-product-card-max-width: none;
 }
Description

Landscape orientation styles

Parameters

None.

Requires
Used by

card-landscape-extended

@mixin card-landscape-extended() { ... }@mixin card-landscape-extended() { 
  container-type: inline-size;
  grid-template-columns: #{settings.$landscape-grid-extended-settings};
 }
Description

Extended landscape styles for the card

Parameters

None.

card-landscape-extended-container

@mixin card-landscape-extended-container() { ... }@mixin card-landscape-extended-container() { 
  @include card-landscape-extended;
 }
Description

Extended landscape styles with container query support

Parameters

None.

Requires

card-landscape-extended-container-query

@mixin card-landscape-extended-container-query() { ... }@mixin card-landscape-extended-container-query() { 
  @container (min-width: #{unit.rem(660px)}) {
    @include card-landscape-extended-large;
  }
 }
Description

Container query for extended landscape large variant Must be called within the card selector to properly query the card's width (not the parent container). The container query is placed at the same level as the selector where this mixin is included.

Parameters

None.

Requires

card-landscape-group

@mixin card-landscape-group() { ... }@mixin card-landscape-group() { 
  grid-auto-columns: #{settings.$landscape-grid-landscape-group-settings};
 }
Description

Extended landscape styles for the card

Parameters

None.

card-landscape-extended-large

@mixin card-landscape-extended-large() { ... }@mixin card-landscape-extended-large() { 
  grid-template-columns:
    min(18rem, max(8rem, 30%))
    1fr #{settings.$actions-landscape-extended-width};
 }
Description

Extended landscape large styles for the card

Parameters

None.

card-landscape-flat

Deprecated!

Kept to avoid breaking change

@mixin card-landscape-flat() { ... }@mixin card-landscape-flat() { 
  @warn "card-landscape-flat mixin is deprecated";
 }
Description

Flat landscape variant styles

Parameters

None.

card-canvas-only

@mixin card-canvas-only() { ... }@mixin card-canvas-only() { 
  --kib-product-card-max-width: #{settings.$max-width};
 }
Description

Card only contains canvas styles

Parameters

None.

Requires

card-condensed

@mixin card-condensed() { ... }@mixin card-condensed() { 
  width: settings.$condensed-width;

  --kib-product-card-min-width: #{settings.$condensed-width};
 }
Description

Condensed card styles

Parameters

None.

Requires

canvas-flat

@mixin canvas-flat() { ... }@mixin canvas-flat() { 
  border-radius: settings.$border-radius settings.$border-radius 0 0;
 }
Description

Canvas styles when parent has no border

Parameters

None.

Requires

canvas-landscape

@mixin canvas-landscape() { ... }@mixin canvas-landscape() { 
  --kib-product-card-canvas-height: auto;

  grid-column: 1;
  grid-row: 1 / 3;
  border-radius: settings.$border-radius-inner 0 0 settings.$border-radius-inner;
 }
Description

Canvas landscape styles

Parameters

None.

Requires
Used by

canvas-landscape-flat

@mixin canvas-landscape-flat() { ... }@mixin canvas-landscape-flat() { 
  border-radius: settings.$border-radius 0 0 settings.$border-radius;
 }
Description

Canvas landscape styles when parent has no border

Parameters

None.

Requires

canvas-landscape-extended

@mixin canvas-landscape-extended() { ... }@mixin canvas-landscape-extended() { 
  padding: spacing.get('s4');
  grid-row: 1;
 }
Description

Canvas extended landscape styles

Parameters

None.

Requires

canvas-landscape-extended-container

@mixin canvas-landscape-extended-container() { ... }@mixin canvas-landscape-extended-container() { 
  @include canvas-landscape-extended;

  @container (min-width: #{unit.rem(440px)}) and (max-width: #{unit.rem(659px)}) {
    @include canvas-landscape-extended-medium;
  }
 }
Description

Canvas extended landscape styles with container query support

Parameters

None.

canvas-landscape-extended-medium

@mixin canvas-landscape-extended-medium() { ... }@mixin canvas-landscape-extended-medium() { 
  grid-row: 1 / 3;
 }
Description

Canvas extended medium landscape styles

Parameters

None.

canvas-only

@mixin canvas-only() { ... }@mixin canvas-only() { 
  width: 100%;
  border-radius: settings.$border-radius-inner;
 }
Description

Canvas only styles

Parameters

None.

Requires

canvas-only-flat

@mixin canvas-only-flat() { ... }@mixin canvas-only-flat() { 
  border-radius: settings.$border-radius;
 }
Description

Canvas only styles when parent has no border

Parameters

None.

Requires

canvas-content

@mixin canvas-content() { ... }@mixin canvas-content() { 
  padding: spacing.get('s2');
  text-align: center;
 }
Description

Canvas content styles

Parameters

None.

Requires

overlay

@mixin overlay() { ... }@mixin overlay() { 
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: settings.$canvas-overlay-background;
  opacity: settings.$canvas-overlay-opacity;
  pointer-events: none;
 }
Description

Overlay over canvas styles

Parameters

None.

flag-container

@mixin flag-container() { ... }@mixin flag-container() { 
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
 }
Description

Flag styles

Parameters

None.

choices

@mixin choices() { ... }@mixin choices() { 
  display: inline-flex;
  justify-content: center;
  width: 100%;
  text-align: center;
  color: settings.$canvas-text-color;
 }
Description

More choices available styles

Parameters

None.

Requires

choices-landscape

@mixin choices-landscape() { ... }@mixin choices-landscape() { 
  padding: spacing.get('s2');
  padding-bottom: 0;

  > :last-child {
    margin-bottom: 0;
  }
 }
Description

More choices available landscape styles

Parameters

None.

Requires
Used by

choices-portrait-spacing

@mixin choices-portrait-spacing() { ... }@mixin choices-portrait-spacing() { 
  $spacing: if($is-condensed == condensed, settings.$spacing, settings.$spacing-base);

  margin-top: calc(0.4rem - $spacing);
 }
Description

More choices available portrait spacing

Parameters

None.

Requires

content

@mixin content() { ... }@mixin content() { 
  padding: var(--kib-product-card-content-padding, #{settings.$spacing-base});
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-grow: 1;
  flex-direction: column;

  & > :last-child {
    margin-bottom: 0;
  }
 }
Description

Default content wrapper styles

Parameters

None.

Requires

content-landscape

@mixin content-landscape() { ... }@mixin content-landscape() { 
  --kib-product-card-content-padding: #{settings.$spacing};

  overflow: hidden;
  grid-column: 2;
  grid-row: 1;
 }
Description

Content landscape styles

Parameters

None.

Requires
Used by

content-landscape-extended

@mixin content-landscape-extended() { ... }@mixin content-landscape-extended() { 
  --kib-product-card-content-padding: #{settings.$spacing-base};
 }
Description

Extended landscape styles for content

Parameters

None.

Requires

content-flat

@mixin content-flat() { ... }@mixin content-flat() { 
  padding-left: 0;
  padding-right: 0;
 }
Description

Content flat styles

Parameters

None.

content-bottom

@mixin content-bottom() { ... }@mixin content-bottom() { 
  margin-top: auto;
  width: 100%;

  & > :last-child {
    margin-bottom: 0;
  }
 }
Description

Bottom aligned content styles

Parameters

None.

content-condensed

@mixin content-condensed() { ... }@mixin content-condensed() { 
  --kib-product-card-content-padding: #{settings.$spacing-condensed};
 }
Description

Condensed content wrapper styles

Parameters

None.

Requires

actions

@mixin actions() { ... }@mixin actions() { 
  padding: 0 settings.$spacing-base settings.$spacing-base;
 }
Description

Default actions wrapper styles

Parameters

None.

Requires

actions-flat

@mixin actions-flat() { ... }@mixin actions-flat() { 
  padding: 0 spacing.get('s1') settings.$spacing-base;
 }
Description

Flat (borderless) styles for the actions wrapper

Parameters

None.

Requires

actions-condensed

@mixin actions-condensed() { ... }@mixin actions-condensed() { 
  padding: 0 settings.$spacing settings.$spacing;
 }
Description

Condensed styles for the actions wrapper

Parameters

None.

Requires

actions-landscape

@mixin actions-landscape() { ... }@mixin actions-landscape() { 
  padding: 0 settings.$spacing settings.$spacing;
  grid-column: 2;
  grid-row: 2;
 }
Description

Landscape styles for the actions wrapper

Parameters

None.

Requires
Used by

actions-landscape-extended

@mixin actions-landscape-extended() { ... }@mixin actions-landscape-extended() { 
  padding: settings.$spacing-base;
  grid-column: 1 / 3;
  grid-row: 2;
 }
Description

Extended landscape styles for the actions wrapper Mobile-first: buttons at bottom, full width

Parameters

None.

Requires

actions-landscape-extended-container

@mixin actions-landscape-extended-container() { ... }@mixin actions-landscape-extended-container() { 
  @include actions-landscape-extended;

  @container (min-width: #{unit.rem(440px)}) and (max-width: #{unit.rem(659px)}) {
    @include actions-landscape-extended-medium;
  }

  @container (min-width: #{unit.rem(660px)}) {
    @include actions-landscape-extended-large;
  }
 }
Description

Extended landscape styles for the actions wrapper with container query support

Parameters

None.

actions-landscape-extended-medium

@mixin actions-landscape-extended-medium() { ... }@mixin actions-landscape-extended-medium() { 
  grid-column: 2;
  grid-row: 2;
 }
Description

Extended landscape medium styles for the actions wrapper Buttons still at bottom, but in second column

Parameters

None.

actions-landscape-extended-large

@mixin actions-landscape-extended-large() { ... }@mixin actions-landscape-extended-large() { 
  padding-left: 0;
  grid-column: 3;
  grid-row: 1;
 }
Description

Extended landscape large styles for the actions wrapper

Parameters

None.

choices-hide

@mixin choices-hide() { ... }@mixin choices-hide() { 
  display: none;
 }
Description

Hide choices component styles

Parameters

None.

generator-landscape

@mixin generator-landscape() { ... }@mixin generator-landscape() { 
  @include card-landscape;

  #{$parent}__canvas {
    @include canvas-landscape;
  }
  #{$parent}__choices {
    @include choices-landscape;

    display: none;

    &--canvas {
      display: inline-flex;
    }
  }
  #{$parent}__content {
    @include content-landscape;
  }
  #{$parent}__actions {
    @include actions-landscape;
  }
 }
Description

Change default card into landscape layout

Parameters

None.

generator-portrait-condensed

@mixin generator-portrait-condensed() { ... }@mixin generator-portrait-condensed() { 
  @include card-condensed;
  #{$parent}__content {
    @include content-condensed;
  }
  #{$parent}__actions {
    @include actions-condensed;
  }
 }
Description

Change default card into condensed layout

Parameters

None.

Requires

generator-landscape-extended

@mixin generator-landscape-extended() { ... }@mixin generator-landscape-extended() { 
  @include generator-landscape;
  @include card-landscape-extended;

  @if $size == large {
    @include card-landscape-extended-large;
  }

  #{$parent}__canvas {
    @include canvas-landscape-extended;

    @if $size == medium {
      @include canvas-landscape-extended-medium;
    }
  }
  #{$parent}__content {
    @include content-landscape-extended;
  }
  #{$parent}__actions {
    @include actions-landscape-extended;

    @if $size == medium {
      @include actions-landscape-extended-medium;
    } @else if $size == large {
      @include actions-landscape-extended-large;
    }
  }
 }
Description

Change default card into landscape extended layout

Parameters

None.

Css

// rather than the canvas area. @mixin canvas

// rather than the canvas area.
@mixin canvas { ... }// rather than the canvas area.
@mixin canvas { padding: var(--kib-product-card-canvas-padding, #{spacing.get('s2')});
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: center;
  align-items: center;
  height: var(--kib-product-card-canvas-height, max-content);
  flex: 0 1 auto;
  min-width: var(--kib-product-card-canvas-min-width, #{settings.$canvas-min-width});
  color: settings.$canvas-text-color;
  background-color: settings.$canvas-background-color;
  border-radius: settings.$border-radius-inner settings.$border-radius-inner 0 0;
  overflow: hidden;

  > :last-child:not(.kib-product-flag) {
    padding-bottom: 0;
    margin-bottom: 0;
  } }
Description

Canvas styles if exploring wider product cards where image area height must stay the same. atm, product card can only handle square images, so change the max-width of kib-product-image

/// Change default card into landscape layout @mixin generator-landscape($parent: '.kib-product-card')

/// Change default card into landscape layout
@mixin generator-landscape($parent: '.kib-product-card') { ... }/// Change default card into landscape layout
@mixin generator-landscape($parent: '.kib-product-card') { @include card-landscape;

  #{$parent}__canvas {
    @include canvas-landscape;
  }
  #{$parent}__choices {
    @include choices-landscape;

    display: none;

    &--canvas {
      display: inline-flex;
    }
  }
  #{$parent}__content {
    @include content-landscape;
  }
  #{$parent}__actions {
    @include actions-landscape;
  } }
Description

Product Card Generators Note, the sibling css selector with parent class is needed ex .kib-product-card.custom-css-name Also note that changing $parent will require changes to all sub components within the card

Variables

max-width

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

Max width of card

Type

Number

min-width

$min-width: unit.rem(200px) !default;
Description

Min width of card

Type

Number

condensed-width

$condensed-width: unit.rem(160px) !default;
Description

Condensed card width

Used by

canvas-text-color

$canvas-text-color: color.get('text', 'tertiary') !default;
Description

Text color for content in canvas

Type

Color

Used by

canvas-background-color

$canvas-background-color: color.get('static', 'gray1', '50') !default;
Description

Background color for content in canvas

Type

Color

canvas-min-width

$canvas-min-width: unit.rem(80px) !default;
Description

Canvas min width

Type

Number

canvas-overlay-background

$canvas-overlay-background: color.get('static', 'gray1', '900') !default;
Description

Color of the canvas overlay

Type

Color

Used by

canvas-overlay-opacity

$canvas-overlay-opacity: 0.03 !default;
Description

Opacity of the canvas overlay

Type

Number

spacing-base

$spacing-base: spacing.get('s4') !default;
Description

Card base spacing

Type

Number

spacing

$spacing: spacing.get('s3') !default;
Description

Margin and padding spacing

Type

Number

spacing-condensed

$spacing-condensed: spacing.get('s3') spacing.get('s2') !default;
Description

Condensed card spacing

Type

Number

Used by

landscape-grid-base-settings

$landscape-grid-base-settings: string.unquote('min(24.8rem, max(8rem, 35%)) 1fr') !default;
Description

Landscape base grid settings (sass thinks min and max are referring to global sass functions)

Type

String

Used by

landscape-grid-extended-settings

$landscape-grid-extended-settings: string.unquote('min(18rem, max(8rem, 35%)) 1fr') !default;
Description

Landscape extended grid settings (sass thinks min and max are referring to global sass functions)

Type

String

landscape-grid-landscape-group-settings

$landscape-grid-landscape-group-settings: string.unquote('min(14rem, max(8rem, 40%)) 1fr') !default;
Description

Landscape group grid settings (sass thinks min and max are referring to global sass functions)

Type

String

Used by

actions-landscape-extended-width

$actions-landscape-extended-width: unit.rem(230px) !default;
Description

Landscape extended width for actions

Type

String

border-radius

$border-radius: card.$border-radius !default;
Description

Default card border-radius

Type

Number

border-radius-inner

$border-radius-inner: $border-radius - card.$border-width !default;
Description

Inner border-radius of card with border

Type

Number

Used by