Chips

Installation

  yarn add @chewy/kib-chips-styles

Import

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

Mixins

chip-base-styles

@mixin chip-base-styles() { ... }@mixin chip-base-styles() { 
  @include kib-foundations.typography-style-as('utility-3');
  @include animation.apply('press', 'scale', 'standard');

  display: inline-flex;
  position: relative;
  box-sizing: border-box;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: spacing.get('s2');
  width: 100%;
  padding: spacing.get('s2') spacing.get('s3');
  border-width: border.get('ct', 'chip', 'border-width', 'standard');
  border-radius: border.get('ct', 'chip', 'border-radius', 'standard');
  font-weight: typography.get-weight('utility-weight-strong');

  cursor: pointer;
 }
Description

Shared styles for chips

Parameters

None.

Requires
Author
  • CDS

chip-container-styles

@mixin chip-container-styles() { ... }@mixin chip-container-styles() { 
  display: inline-block;
  vertical-align: middle;

  & + & {
    margin-left: spacing.get('s2');
  }
 }
Description

Shared outer container styles for wrapped chips

Parameters

None.

Requires
Author
  • CDS

chip-disabled-styles

@mixin chip-disabled-styles() { ... }@mixin chip-disabled-styles() { 
  opacity: 0.4;
  pointer-events: none;
 }
Description

Common disabled styles

Parameters

None.

Author
  • CDS

chip-icon-styles

@mixin chip-icon-styles() { ... }@mixin chip-icon-styles() { 
  position: relative;
  width: unit.rem(18px);
  height: unit.rem(18px);
 }
Description

Common icon styles for chips

Parameters

None.

Requires
Author
  • CDS

chip-enabled-styles

@mixin chip-enabled-styles() { ... }@mixin chip-enabled-styles() { 
  background: map.get(variants.$styles, $type, '$chip-background');
  color: map.get(variants.$styles, $type, '$chip-text-color');

  &:active {
    background: settings.$chip-pressed-background;
    box-shadow: none;
  }

  &:hover {
    color: map.get(variants.$styles, $type, '$chip-text-color');
  }
 }
Description

Common active styles

Parameters

None.

Requires
Author
  • CDS

legacy-chip-base-styles

@mixin legacy-chip-base-styles($use-hover-elevation: true) { ... }@mixin legacy-chip-base-styles($use-hover-elevation: true) { 
  @include kib-foundations.typography-style-as('paragraph-1');
  display: inline-flex;
  position: relative;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  height: settings.$chip-height;
  transition: background-color 100ms ease-out;
  border: 0;
  border-radius: kib-core.dimensions-get('large');
  background: map.get(variants.$styles, $type, '$default-background');
  color: map.get(variants.$styles, $type, '$default-text-color');
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;

  &:focus {
    outline: none;

    @at-root a#{&} {
      text-decoration: underline;
    }
  }

  &::after {
    $distance: unit.rem(-2px);
    $radius: kib-core.dimensions-get('large');
    content: ' ';

    position: absolute;
    top: $distance;
    right: $distance;
    bottom: $distance;
    left: $distance;
    transition: opacity 100ms ease-out;
    border: none;
    border-radius: $radius + kib-core.dimensions-get(tiny);
    opacity: 0;
    box-shadow: 0 0 0 unit.rem(1px) map.get(variants.$styles, $type, '$chip-focus-border-color');
    pointer-events: none;
  }

  &:hover {
    @if $use-hover-elevation {
      @include elevation.apply('emphasis-primary');
    }

    border: none;
    background: map.get(variants.$styles, $type, '$hover-background');
    color: map.get(variants.$styles, $type, '$default-text-color');
  }

  &:active {
    background: map.get(variants.$styles, $type, '$pressed-background');
    box-shadow: none;
  }
 }
Description

Legacy chip base styles - will be removed in the future

Parameters
Parameters
parameter Nameparameter Descriptionparameter Typeparameter Default value
$use-hover-elevation

Tab chips use false (flat hover; no shadow).

Booleantrue
Requires
Author
  • CDS

legacy-base-styles-adjacent

@mixin legacy-base-styles-adjacent() { ... }@mixin legacy-base-styles-adjacent() { 
  & + & {
    margin-left: spacing.get('s2');
  }
 }
Description

Legacy base styles adjacent - will be removed in the future

Parameters

None.

Requires
Author
  • CDS

legacy-chip-disabled-styles

@mixin legacy-chip-disabled-styles() { ... }@mixin legacy-chip-disabled-styles() { 
  opacity: map.get(variants.$styles, $type, '$chip-disabled-opacity');
  pointer-events: none;

  &:focus,
  &:active,
  &:hover {
    box-shadow: none;
    cursor: default;
  }

  &::after {
    box-shadow: none;
  }
 }
Description

Legacy chip disabled styles - will be removed in the future

Parameters

None.

Requires
Author
  • CDS

legacy-chip-focus-styles

@mixin legacy-chip-focus-styles() { ... }@mixin legacy-chip-focus-styles() { 
  &::after {
    opacity: 1;
  }
 }
Description

Legacy chip focus styles - will be removed in the future

Parameters

None.

Author
  • CDS

legacy-chip-active-hover-styles

@mixin legacy-chip-active-hover-styles() { ... }@mixin legacy-chip-active-hover-styles() { 
  &::after {
    opacity: 0;
  }
 }
Description

Legacy chip active hover styles - will be removed in the future

Parameters

None.

Author
  • CDS

legacy-chip-icon-styles

@mixin legacy-chip-icon-styles() { ... }@mixin legacy-chip-icon-styles() { 
  position: relative;
  width: settings.$chip-icon-size;
  height: settings.$chip-icon-size;
  color: map.get(variants.$styles, $type, '$chip-icon-color');

  > svg {
    display: inline-block;
    fill: map.get(variants.$styles, $type, '$chip-icon-color');
  }
 }
Description

Legacy chip icon styles - will be removed in the future

Parameters

None.

Requires
Author
  • CDS

legacy-chip-content-spacing

@mixin legacy-chip-content-spacing() { ... }@mixin legacy-chip-content-spacing() { 
  padding: {
    top: settings.$chip-spacing-vertical;
    right: settings.$chip-spacing-horizontal;
    bottom: settings.$chip-spacing-vertical;
    left: settings.$chip-spacing-horizontal;
  }
 }
Description

Legacy chip content spacing - will be removed in the future

Parameters

None.

Requires
Author
  • CDS

chip-deselected-styles

@mixin chip-deselected-styles() { ... }@mixin chip-deselected-styles() { 
  border: kib-foundations.rem(1px) solid
    map.get(variants.$styles, $type, '$chip-deselected-border-color');
  background: map.get(variants.$styles, $type, '$chip-deselected-background');
  color: map.get(variants.$styles, $type, '$chip-deselected-text-color');

  &:hover {
    border: kib-foundations.rem(1px) solid
      map.get(variants.$styles, $type, '$chip-deselected-border-color');
    background: map.get(variants.$styles, $type, '$chip-deselected-hover-background');
    color: map.get(variants.$styles, $type, '$chip-deselected-text-color');
  }

  &:active {
    border: kib-foundations.rem(1px) solid
      map.get(variants.$styles, $type, '$chip-deselected-border-color');
    background: map.get(variants.$styles, $type, '$chip-deselected-active-background');
  }
 }
Description

Legacy common deselected styles - will be removed in the future

Parameters

None.

Requires
Author
  • CDS

Variables

default-background

Deprecated!

Kept to avoid breaking change

$default-background: color.get('chip', '01', 'bg-primary') !default;
Description

Default background color

Type

Color

Author
  • CDS

pressed-background

Deprecated!

Kept to avoid breaking change

$pressed-background: color.get('chip', '01', 'bg-high') !default;
Description

Default Pressed background color

Type

Color

Author
  • CDS

default-text-color

Deprecated!

Kept to avoid breaking change

$default-text-color: color.get('chip', '01', 'text') !default;
Description

Default text color

Type

Color

Author
  • CDS

chip-icon-color

Deprecated!

Kept to avoid breaking change

$chip-icon-color: color.get('chip', '03', 'text') !default;
Description

Default icon color

Type

Color

Author
  • CDS

chip-text-color

Deprecated!

Kept to avoid breaking change

$chip-text-color: color.get('chip', '03', 'text') !default;
Description

Default chip text color

Type

Color

Used by
Author
  • CDS

chip-background

Deprecated!

Kept to avoid breaking change

$chip-background: color.get('chip', '03', 'bg-primary') !default;
Description

Default chip background color

Type

Color

Used by
Author
  • CDS

chip-pressed-background

Deprecated!

Kept to avoid breaking change

$chip-pressed-background: color.get('chip', '03', 'bg-high') !default;
Description

Default chip pressed background color

Type

Color

Used by
Author
  • CDS

chip-height

Deprecated!

Kept to avoid breaking change

$chip-height: kib-core.dimensions-get(default) * 2.25 !default;
Description

Default chip height

Type

Number

Author
  • CDS

chip-focus-border-color

Deprecated!

Kept to avoid breaking change

$chip-focus-border-color: color.get('chip', '03', 'text') !default;
Description

Default chip focus border color

Type

Color

Author
  • CDS

chip-disabled-opacity

Deprecated!

Kept to avoid breaking change

$chip-disabled-opacity: 0.3 !default;
Description

Default chip disabled opacity

Type

Number

Author
  • CDS

chip-icon-size

Deprecated!

Kept to avoid breaking change

$chip-icon-size: kib-core.dimensions-get(default) * 1.25 !default;
Description

Default icon size

Type

Number

Author
  • CDS

chip-spacing-vertical

Deprecated!

Kept to avoid breaking change

$chip-spacing-vertical: spacing.get('s2') !default;
Description

Default chip vertical spacing

Type

Number

Author
  • CDS

chip-spacing-horizontal

Deprecated!

Kept to avoid breaking change

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

Default chip horizontal spacing

Type

Number

Author
  • CDS