// Table of Contents // ================================================== // Switch // Sizes // Colors // Switch // ================================================== .switch { border: 1px solid; border-color: color(haze); border-radius: border-radius(xl); box-shadow: 0 0 3px darkish-color(haze); cursor: pointer; display: inline-block; height: 28px; overflow: hidden; position: relative; vertical-align: top; width: 56px; input[type='checkbox'], input[type='radio'] { left: -9999px; margin: 0; padding: 0; position: absolute; visibility: hidden; top: -9999px; } .switch-group { @include transition(left 0.125s ease-in-out); @include user-select(none); border-color: inherit; bottom: 0; height: 100%; left: 0; position: absolute; top: 0; width: 200%; } .switch-handle { @include transition(right 0.125s ease-in-out); background: color(white); border: 1px solid; border-color: inherit; border-radius: border-radius(xl); box-sizing: border-box; display: block; height: 28px; left: initial; position: absolute; right: calc(50% - 1px); width: 28px; } .switch-off, .switch-on { border-radius: border-radius(xl); bottom: 0; box-sizing: border-box; margin: 0; padding-top: 5px; position: absolute; top: 0; } .switch-off { left: 50%; padding-right: 10px; right: 0; text-align: right; } .switch-on { left: 0; padding-left: 10px; right: 50%; } &.off { .switch-group { left: -100%; } .switch-handle { left: calc(50% - 1px); right: initial; } } &.disabled { cursor: not-allowed; * { cursor: not-allowed; } } &.dark { box-shadow: 0 0 3px darkish-color(dark-slate); .switch-handle { background: color(light-slate); } } &.light { .switch-handle { background: color(haze); } } } // Sizes // ================================================== .switch-size-l { height: 36px; width: 76px; .switch-handle { height: 36px; width: 36px; } .switch-off, .switch-on { font-size: text-size(l); padding-top: 7px; } .switch-off { padding-right: 14px; } .switch-on { padding-left: 14px; } } .switch-size-m { height: 32px; width: 66px; .switch-handle { height: 32px; width: 32px; } .switch-off, .switch-on { font-size: text-size(l); } .switch-off { padding-right: 12px; } .switch-on { padding-left: 12px; } } .switch-size-s { height: 24px; width: 48px; .switch-handle { height: 24px; width: 24px; } .switch-off, .switch-on { font-size: text-size(s); } .switch-off { padding-right: 8px; } .switch-on { padding-left: 8px; } } // Colors // ================================================== @each $name, $color in $colors { .switch-color-#{$name} { background: color($name); border-color: darkish-color($name); color: text-color-on($name); } }