Newer
Older
vmk-ui-kit / src / scss / components / _radio.scss
@Eugene Sukhodolskiy Eugene Sukhodolskiy 1 day ago 1 KB Add Checkbox, Radio, and Switch components
/* =========================
   Radio
========================= */

@use "../kit-deps" as *;

.radio {
  display: inline-flex;
  align-items: center;
  gap: $space-2;
  cursor: pointer;
  font-size: 15px;
  color: $neutral-900;

  input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: 0;
  }

  .radio-control {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 1px solid $neutral-400;
    border-radius: 50%;
    background-color: $neutral-0;
    position: relative;
    transition:
      border-color $motion-base $motion-ease,
      background-color $motion-base $motion-ease;

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      margin: auto;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background-color: $neutral-0;
      transform: scale(0);
      transition: transform $motion-base $motion-ease;
    }
  }

  &:hover .radio-control {
    border-color: $mint-600;
  }

  input[type="radio"]:focus-visible + .radio-control {
    @include focus_ring;
  }

  input[type="radio"]:checked + .radio-control {
    background-color: $mint-600;
    border-color: $mint-600;

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

  input[type="radio"]:disabled + .radio-control {
    background-color: $neutral-100;
    border-color: $neutral-300;
    cursor: not-allowed;
  }

  input[type="radio"]:checked:disabled + .radio-control {
    background-color: $neutral-400;
    border-color: $neutral-400;
  }

  input[type="radio"]:disabled ~ .radio-label {
    color: $neutral-500;
    cursor: not-allowed;
  }

  .radio-label {
    font-weight: $font-weight-medium;
    line-height: 1.25;
  }
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: $space-2;

  > .label {
    font-size: 14px;
    font-weight: $font-weight-semibold;
    color: $neutral-900;
    margin-bottom: $space-1;
  }
}