/* ToggleSwitch */ /* Catalyst in dotcom applies a display: block to all web component elements. This ** rule overrides it so the status label and toggle switch are laid out correctly. */ .ToggleSwitch.ToggleSwitch { display: inline-flex; } .ToggleSwitch { align-items: center; display: inline-flex; gap: var(--controlStack-medium-gap-condensed); } .ToggleSwitch--checked { & .ToggleSwitch-statusOn { height: auto; visibility: visible; } & .ToggleSwitch-statusOff { height: 0; visibility: hidden; } } .ToggleSwitch-track { position: relative; display: block; width: var(--base-size-64); height: var(--control-medium-size); padding: 0; overflow: hidden; text-decoration: none; cursor: pointer; user-select: none; background-color: var(--controlTrack-bgColor-rest); border: var(--borderWidth-thin) solid var(--controlTrack-borderColor-rest); border-radius: var(--borderRadius-medium); transition-timing-function: cubic-bezier(0.5, 1, 0.89, 1); transition-duration: 80ms; transition-property: background-color, border-color; appearance: none; &:focus, &:focus-visible { outline-offset: 1px; } &:hover { background-color: var(--controlTrack-bgColor-hover); } &:active { background-color: var(--controlTrack-bgColor-active); } @media (pointer: coarse) { &::before { @mixin minTouchTarget 44px; } } @media (prefers-reduced-motion) { transition: none; & * { transition: none; } } } .ToggleSwitch-track[aria-pressed='true'][disabled] { background-color: var(--controlTrack-bgColor-disabled); color: var(--control-checked-fgColor-disabled); border-color: transparent; } .ToggleSwitch-track[aria-pressed='true'] { background-color: var(--control-checked-bgColor-rest); border-color: var(--borderColor-transparent); &:not([disabled]) { &:hover { background-color: var(--control-checked-bgColor-hover); } &:active { background-color: var(--control-checked-bgColor-active); } } & .ToggleSwitch-knob { background-color: var(--controlKnob-bgColor-checked); border-color: var(--controlKnob-borderColor-checked); transform: translateX(100%); } & .ToggleSwitch-lineIcon { transform: translateX(0%); } & .ToggleSwitch-circleIcon { transform: translateX(100%); } } .ToggleSwitch-track[disabled] { cursor: not-allowed; background-color: var(--controlTrack-bgColor-disabled); border-color: transparent; transition-property: none; & .ToggleSwitch-knob { border-color: var(--borderColor-default); box-shadow: none; } & .ToggleSwitch-lineIcon { color: var(--controlTrack-fgColor-disabled); } & .ToggleSwitch-circleIcon { color: var(--controlTrack-fgColor-disabled); } } .ToggleSwitch-icons { display: flex; align-items: center; width: 100%; height: 100%; overflow: hidden; } .ToggleSwitch-lineIcon { line-height: 0; color: var(--control-checked-fgColor-rest); transition-duration: 80ms; transition-property: transform; transform: translateX(-100%); flex: 1 0 50%; } .ToggleSwitch-circleIcon { line-height: 0; color: var(--controlTrack-fgColor-rest); transition-duration: 80ms; transition-property: transform; transform: translateX(0); flex: 1 0 50%; } .ToggleSwitch-knob { position: absolute; top: 0; bottom: 0; z-index: 1; width: 50%; background-color: var(--controlKnob-bgColor-rest); border: var(--borderWidth-thin) solid var(--controlKnob-borderColor-rest); border-radius: var(--borderRadius-medium); box-shadow: var(--shadow-resting-medium), var(--button-default-shadow-inset); transition-timing-function: cubic-bezier(0.5, 1, 0.89, 1); transition-duration: 80ms; transition-property: transform; @media (prefers-reduced-motion) { transition: none; } } .ToggleSwitch-status { position: relative; font-size: var(--text-body-size-medium); line-height: 1.5; color: var(--fgColor-default); text-align: right; } .ToggleSwitch-statusIcon { width: var(--base-size-16); display: flex; margin-top: 0.063rem; } .ToggleSwitch--small { & .ToggleSwitch-status { font-size: var(--text-body-size-small); } & .ToggleSwitch-track { width: var(--base-size-48); height: var(--control-xsmall-size); } } .ToggleSwitch--disabled { & .ToggleSwitch-status { color: var(--fgColor-muted); } } .ToggleSwitch-statusOn { height: 0; visibility: hidden; } .ToggleSwitch-statusOff { height: auto; visibility: visible; } .ToggleSwitch--statusAtEnd { flex-direction: row-reverse; & .ToggleSwitch-status { text-align: left; } }