Source code

Revision control

Copy as Markdown

Other Tools

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@import url("chrome://global/skin/design-system/text-and-typography.css");
:host {
display: flex;
flex-direction: column;
gap: var(--space-xsmall);
}
:host([disabled]) {
opacity: 0.4
}
::slotted(a[is="moz-support-link"]) {
display: inline-block;
}
#moz-toggle-label {
display: flex;
justify-content: space-between;
align-items: center;
gap: var(--space-small);
}
.description-wrapper,
.description-wrapper ::slotted([slot="support-link"]) {
margin: 0;
}
.toggle-button {
--toggle-background-color: var(--button-background-color);
--toggle-background-color-hover: var(--button-background-color-hover);
--toggle-background-color-active: var(--button-background-color-active);
--toggle-background-color-pressed: var(--color-accent-primary);
--toggle-background-color-pressed-hover: var(--color-accent-primary-hover);
--toggle-background-color-pressed-active: var(--color-accent-primary-active);
--toggle-border-color: var(--border-color-interactive);
--toggle-border-color-hover: var(--toggle-border-color);
--toggle-border-color-active: var(--toggle-border-color);
--toggle-border-radius: var(--border-radius-circle);
--toggle-border-width: var(--border-width);
--toggle-height: var(--size-item-small);
--toggle-width: var(--size-item-large);
--toggle-dot-background-color: var(--toggle-border-color);
--toggle-dot-background-color-hover: var(--toggle-dot-background-color);
--toggle-dot-background-color-active: var(--toggle-dot-background-color);
--toggle-dot-background-color-on-pressed: var(--background-color-canvas);
--toggle-dot-margin: 1px;
--toggle-dot-height: calc(var(--toggle-height) - 2 * var(--toggle-dot-margin) - 2 * var(--toggle-border-width));
--toggle-dot-width: var(--toggle-dot-height);
--toggle-dot-transform-x: calc(var(--toggle-width) - 4 * var(--toggle-dot-margin) - var(--toggle-dot-width));
}
.toggle-button {
appearance: none;
padding: 0;
margin: 0;
border: var(--toggle-border-width) solid var(--toggle-border-color);
height: var(--toggle-height);
width: var(--toggle-width);
border-radius: var(--toggle-border-radius);
background: var(--toggle-background-color);
box-sizing: border-box;
flex-shrink: 0;
}
.toggle-button:focus-visible {
outline: var(--focus-outline);
outline-offset: var(--focus-outline-offset);
}
.toggle-button:enabled:hover {
background: var(--toggle-background-color-hover);
border-color: var(--toggle-border-color);
}
.toggle-button:enabled:hover:active {
background: var(--toggle-background-color-active);
border-color: var(--toggle-border-color);
}
.toggle-button[aria-pressed="true"] {
background: var(--toggle-background-color-pressed);
border-color: transparent;
}
.toggle-button[aria-pressed="true"]:enabled:hover {
background: var(--toggle-background-color-pressed-hover);
border-color: transparent;
}
.toggle-button[aria-pressed="true"]:enabled:hover:active {
background: var(--toggle-background-color-pressed-active);
border-color: transparent;
}
.toggle-button::before {
display: block;
content: "";
background-color: var(--toggle-dot-background-color);
height: var(--toggle-dot-height);
width: var(--toggle-dot-width);
margin: var(--toggle-dot-margin);
border-radius: var(--toggle-border-radius);
translate: 0;
}
.toggle-button[aria-pressed="true"]::before {
translate: var(--toggle-dot-transform-x);
background-color: var(--toggle-dot-background-color-on-pressed);
}
.toggle-button[aria-pressed="true"]:enabled:hover::before,
.toggle-button[aria-pressed="true"]:enabled:hover:active::before {
background-color: var(--toggle-dot-background-color-on-pressed);
}
.toggle-button[aria-pressed="true"]:-moz-locale-dir(rtl)::before,
.toggle-button[aria-pressed="true"]:dir(rtl)::before {
translate: calc(-1 * var(--toggle-dot-transform-x));
}
@media (prefers-reduced-motion: no-preference) {
.toggle-button::before {
transition: translate 100ms;
}
}
@media (prefers-contrast) {
:host([disabled]) {
opacity: 1;
}
:host([disabled]) > .toggle-button[aria-pressed="true"],
:host([disabled]) > .toggle-button {
background-color: var(--toggle-background-color-disabled);
border-color: var(--toggle-border-color-disabled);
}
:host([disabled]) > .toggle-button[aria-pressed="false"]::before,
:host([disabled]) > .toggle-button[aria-pressed="true"]::before {
background-color: var(--toggle-background-color-disabled);
}
.toggle-button:enabled:hover {
border-color: var(--toggle-border-color-hover);
}
.toggle-button:enabled:hover:active {
border-color: var(--toggle-border-color-active);
}
.toggle-button[aria-pressed="true"]:enabled {
border-color: var(--toggle-border-color);
position: relative;
}
.toggle-button[aria-pressed="true"]:enabled:hover,
.toggle-button[aria-pressed="true"]:enabled:hover:active {
border-color: var(--toggle-border-color-hover);
}
.toggle-button[aria-pressed="true"]:enabled:hover:active {
background-color: var(--toggle-dot-background-color-active);
border-color: var(--toggle-dot-background-color-hover);
}
.toggle-button:hover::before,
.toggle-button:hover:active::before {
background-color: var(--toggle-dot-background-color-hover);
}
}
@media (forced-colors) {
.toggle-button {
--toggle-dot-background-color: var(--color-accent-primary);
--toggle-dot-background-color-hover: var(--color-accent-primary-hover);
--toggle-dot-background-color-active: var(--color-accent-primary-active);
--toggle-dot-background-color-on-pressed: var(--button-background-color);
--toggle-background-color-disabled: var(--button-background-color-disabled);
--toggle-border-color-hover: var(--border-color-interactive-hover);
--toggle-border-color-active: var(--border-color-interactive-active);
--toggle-border-color-disabled: var(--border-color-interactive-disabled);
}
.toggle-button[aria-pressed="true"]:enabled::after {
border: 1px solid var(--button-background-color);
content: '';
position: absolute;
height: var(--toggle-height);
width: var(--toggle-width);
display: block;
border-radius: var(--toggle-border-radius);
inset: -2px;
}
.toggle-button[aria-pressed="true"]:enabled:hover:active::after {
border-color: var(--toggle-border-color-active);
}
}