Choices

Installation

  yarn add @chewy/kib-choices-styles

Import

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

Mixins

choice-root

@mixin choice-root() { ... }@mixin choice-root() { 
  margin-bottom: spacing.get('s4');
 }
Description

Root container of choice component

Parameters

None.

Requires

choice-field

@mixin choice-field() { ... }@mixin choice-field() { 
  position: relative;
  display: flex;
  align-items: center;
 }
Description

Field wrapper of choice control and label

Parameters

None.

choice-control-native

@mixin choice-control-native($width, $height) { ... }@mixin choice-control-native($width, $height) { 
  position: absolute;
  margin: 0;
  width: $width;
  height: $height;
  appearance: none;
  cursor: pointer;
  opacity: 0;

  &:disabled {
    pointer-events: none;
  }
 }
Description

Common choice native input control styles

Parameters
Parameters
parameter Nameparameter Descriptionparameter Typeparameter Default value
$width

input control width

Number none
$height

input control height

Number none
Requires

choice-control-custom

@mixin choice-control-custom($block, $width, $height) { ... }@mixin choice-control-custom($block, $width, $height) { 
  position: relative;
  display: block;
  width: $width;
  height: $height;
  border: settings.$border-width solid settings.$border-color;
  border-radius: 50%;
  flex-shrink: 0;
  pointer-events: none;

  &::after {
    $distance: settings.$border-width * -3;

    position: absolute;
    top: $distance;
    left: $distance;
    right: $distance;
    bottom: $distance;
    border: settings.$border-width solid settings.$outline-color;
    border-radius: 50%;
    content: '';
    opacity: 0;
    transform: scale(0.75);
    transition-property: opacity, transform;
    transition-duration: 0.2s;
  }

  #{$block}__native:focus ~ & {
    border-color: settings.$border-color-focus;

    &::after {
      opacity: 1;
      transform: scale(1);
    }
  }

  #{$block}__native:checked ~ & {
    border-color: settings.$border-color-checked;
  }

  #{$block}__native:disabled ~ & {
    opacity: 0.5;
    pointer-events: none;
  }

  #{$block}__native:disabled:not(:checked) ~ & {
    background-color: settings.$disabled-background-color;
  }
 }
Description

Common custom input control styles with various states

Parameters
Parameters
parameter Nameparameter Descriptionparameter Typeparameter Default value
$block

root class of parent block element

String none
$width

input control width

Number none
$height

input control height

Number none
Requires

choice-label

@mixin choice-label() { ... }@mixin choice-label() { 
  @include typography.style-as('paragraph-1');

  margin-left: settings.$label-spacing;
  color: settings.$label-text-color;
  cursor: pointer;

  #{$block}__native:disabled ~ & {
    color: settings.$label-text-color-disabled;
    pointer-events: none;
  }
 }
Description

Base styles for choice labels

Parameters

None.

Requires

choice-append-container

@mixin choice-append-container($width) { ... }@mixin choice-append-container($width) { 
  margin-top: spacing.get('s2');
  padding-left: calc(#{$width} + #{settings.$label-spacing});
 }
Description

Container that holds appended content below choice label

Parameters
Parameters
parameter Nameparameter Descriptionparameter Typeparameter Default value
$width

input control width

Number none
Requires

Variables

brand

$brand: color.get('action', 'selection-control', 'on', 'primary') !default;
Description

Brand color applied to the components

Type

Color

Author
  • CDS

brand-emphasis

$brand-emphasis: color.get('action', 'selection-control', 'on', '02') !default;
Description

Brand color applied to some components' various emphasis states

Type

Color

Author
  • CDS

border-color

$border-color: color.get('action', 'selection-control', 'off', 'primary') !default;
Description

Unchecked default border color

Type

Color

Author
  • CDS

border-color-focus

$border-color-focus: $brand !default;
Description

Border color when focused

Type

Color

Author
  • CDS

border-color-checked

$border-color-checked: $brand !default;
Description

Border color when checked

Type

Color

Author
  • CDS

border-width

$border-width: unit.rem(1px) !default;
Description

Border width

Type

Number

Author
  • CDS

disabled-background-color

$disabled-background-color: color.get('ui-bg', '02') !default;
Description

Disabled state background color

Type

Color

Used by
Author
  • CDS

outline-color

$outline-color: $brand !default;
Description

Color of outline when focused

Type

Color

Used by
Author
  • CDS

width

$width: $size !default;
Description

Custom width if different from $size

Type

Number

Author
  • CDS

height

$height: $size !default;
Description

Custom height if different from $size

Type

Number

Author
  • CDS

label-align

$label-align: flex-start !default;
Description

Flexbox property to set vertical alignment between choice control and label

Type

String

Author
  • CDS

label-spacing

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

Spacing between choice control and label

Type

Number

Used by
Author
  • CDS

label-text-color

$label-text-color: inherit !default;
Description

Label text color

Type

Color

Used by
Author
  • CDS

label-text-color-disabled

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

Label text color while control is disabled

Type

Color

Used by
Author
  • CDS