Switch.module.css 1.05 KB
.switch {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 22px;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--gl-color-text-secondary);
  cursor: pointer;
  transition:
    background-color 120ms ease,
    opacity 120ms ease;
}

.switch:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--gl-color-primary) 24%, transparent);
  outline-offset: 2px;
}

.switch:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.checked {
  background: var(--gl-color-primary);
}

.handle {
  position: absolute;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(16 24 40 / 16%);
  transition: transform 120ms ease;
}

.checked .handle {
  transform: translateX(16px);
}

.loading .handle::after {
  position: absolute;
  inset: 4px;
  border: 1px solid var(--gl-color-primary);
  border-top-color: transparent;
  border-radius: 999px;
  animation: spin 720ms linear infinite;
  content: '';
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}