$toggle-switch-width: 2.8rem; $toggle-switch-height: 1.6rem; $toggle-switch-toggle-padding: 3px; $toggle-switch-toggle-width: calc($toggle-switch-height - $toggle-switch-toggle-padding * 2); $toggle-switch-toggle-end-pos: calc($toggle-switch-width - ($toggle-switch-toggle-width + $toggle-switch-toggle-padding * 2)); $toggle-switch-compact-width: 2.1rem; $toggle-switch-compact-height: 1.2rem; $toggle-switch-compact-toggle-padding: 2px; $toggle-switch-compact-toggle-width: calc($toggle-switch-compact-height - $toggle-switch-compact-toggle-padding * 2); $toggle-switch-compact-toggle-end-pos: calc($toggle-switch-compact-width - ($toggle-switch-compact-toggle-width + $toggle-switch-compact-toggle-padding * 2)); .tp__toggle-switch { position: relative; display: inline-block; width: $toggle-switch-width; min-width: $toggle-switch-width; max-width: $toggle-switch-width; height: $toggle-switch-height; cursor: pointer; border: 2px solid transparent; border-radius: var(--border-radius); &__readonly { cursor: default; } input { opacity: 0; width: 0; height: 0 } input:checked + span { background-color: var(--toggle-switch-on-background-color); } input:checked + span > span { transform: translateX($toggle-switch-toggle-end-pos); } &__track { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--toggle-switch-off-background-color); border-radius: $toggle-switch-toggle-width; transition: 0.3s; } &__toggle { position: absolute; height: $toggle-switch-toggle-width; width: $toggle-switch-toggle-width; left: $toggle-switch-toggle-padding; bottom: $toggle-switch-toggle-padding; background-color: var(--toggle-switch-toggle-color); border-radius: 50%; transition: 0.3s; transform: translateX(0); box-shadow: var(--toggle-switch-toggle-shadow); } &__active { } &:focus-within { border-color: var(--input-focus-border-color); } &--compact { width: $toggle-switch-compact-width; min-width: $toggle-switch-compact-width; max-width: $toggle-switch-compact-width; height: $toggle-switch-compact-height; .tp__toggle-switch__track { border-radius: $toggle-switch-compact-toggle-width; } .tp__toggle-switch__toggle { height: $toggle-switch-compact-toggle-width; width: $toggle-switch-compact-toggle-width; left: $toggle-switch-compact-toggle-padding; bottom: $toggle-switch-compact-toggle-padding; } input:checked + span > span { transform: translateX($toggle-switch-compact-toggle-end-pos); } } }