form--checkbox-toggle.css

Same filename and directory in other branches
  1. 11.x core/themes/default_admin/css/components/form--checkbox-toggle.css
/*
 * DO NOT EDIT THIS FILE.
 * See the following change record for more information,
 * https://www.drupal.org/node/3084859
 * @preserve
 */

/*
 * @file
 * Single checkbox: show as toggle.
 */

:not(.form-checkboxes, td, .tabledrag-cell-content__item, .media-library-item__click-to-select-checkbox, .field-content, .ajax-new-content, .tablesaw-cell-content) > .form-type--checkbox {
  position: relative;
  margin-inline-start: 0;

  input {
    all: unset;
    appearance: none;
    position: relative;
    display: inline-block;
    overflow: hidden;
    box-sizing: border-box;
    width: 2.5rem;
    height: 1.5rem;
    cursor: pointer;
    vertical-align: top;
    border: 3px solid transparent;
    border-radius: var(--gin-border-l);
    background-color: var(--gin-color-disabled);
    clip-path: circle(var(--gin-spacing-l) at 50% 50%); /* Fix Safari bug */

    .gin--dark-mode & {
      background-color: var(--gin-bg-input);
    }

    &::before {
      position: absolute;
      width: 100%;
      height: 100%;
      content: "";
      transform: translateX(-1rem);
      border-radius: 1.3125rem;
      background-color: #fff;

      &:dir(rtl) {
        transform: translateX(1rem);
      }

      .gin--dark-mode & {
        background-color: var(--gin-border-color-form-element);
      }

      @media (prefers-reduced-motion: no-preference) {
        transition: transform 0.3s;
      }

      @media (forced-colors: active) {
        background-color: CanvasText;
      }
    }

    /* Disabled state: set cursor to not-allowed */
    &:disabled {
      cursor: not-allowed;
    }

    /* Hover state */
    &:hover {
      opacity: 0.9;
      box-shadow: 0 0 2px rgb(0, 0, 0, 0.2);
    }

    /* Hover/Focus state */
    &:active,
    &:focus {
      box-shadow:
        0 0 0 1px var(--gin-color-focus-border),
        0 0 0 4px var(--gin-color-focus);
    }

    /* Active state */
    &:checked {
      background-color: var(--gin-switch);

      .gin--dark-mode & {
        background-color: var(--gin-color-primary-light-active);
      }

      &::before {
        transform: translateX(1rem);
        background-color: #fff;

        &:dir(rtl) {
          transform: translateX(-1rem);
        }

        .gin--dark-mode & {
          background-color: var(--gin-color-primary-hover);
        }

        .gin--high-contrast-mode & {
          background-color: var(--gin-border-color);
        }

        @media (forced-colors: active) {
          padding-inline-start: var(--gin-spacing-xs);
          background-color: LinkText !important;
        }
      }

      @media (forced-colors: active) {
        &::after {
          transform: translateX(1rem);
          mask-image: var(--admin-icon-checked);
          mask-position: 2px 2px;

          &:dir(rtl) {
            transform: translateX(-1rem);
          }
        }
      }
    }

    /* Disabled state */
    &:disabled {
      opacity: 0.75;
      background-color: var(--gin-color-disabled);
      box-shadow: none;

      &::before {
        opacity: 0.6;
        background-color: #fff;
      }
    }

    @media (forced-colors: active) {
      border-width: 2px;
    }

    @media (forced-colors: active) {
      &::after {
        position: absolute;
        width: 100%;
        height: 100%;
        content: "";
        transform: translateX(-1rem);
        background-color: Canvas;
        mask-image: var(--admin-icon-toggle-unchecked);
        mask-size: 1rem 1rem;
        mask-position: 1.0625rem 2px;
        mask-repeat: no-repeat;

        &:dir(rtl) {
          transform: translateX(1rem);
        }

        @media (prefers-reduced-motion: no-preference) {
          transition: transform 0.3s;
        }
      }
    }
  }

  label {
    position: relative;
    z-index: 1;
    padding-block-end: 0;
    padding-inline-start: var(--gin-spacing-xxs);
    color: var(--gin-color-text);
  }
}

File

core/themes/default_admin/css/components/form--checkbox-toggle.css

View source
  1. /*
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/3084859
  5. * @preserve
  6. */
  7. /*
  8. * @file
  9. * Single checkbox: show as toggle.
  10. */
  11. :not(.form-checkboxes, td, .tabledrag-cell-content__item, .media-library-item__click-to-select-checkbox, .field-content, .ajax-new-content, .tablesaw-cell-content) > .form-type--checkbox {
  12. position: relative;
  13. margin-inline-start: 0;
  14. input {
  15. all: unset;
  16. appearance: none;
  17. position: relative;
  18. display: inline-block;
  19. overflow: hidden;
  20. box-sizing: border-box;
  21. width: 2.5rem;
  22. height: 1.5rem;
  23. cursor: pointer;
  24. vertical-align: top;
  25. border: 3px solid transparent;
  26. border-radius: var(--gin-border-l);
  27. background-color: var(--gin-color-disabled);
  28. clip-path: circle(var(--gin-spacing-l) at 50% 50%); /* Fix Safari bug */
  29. .gin--dark-mode
  30. &::before {
  31. position: absolute;
  32. width: 100%;
  33. height: 100%;
  34. content: "";
  35. transform: translateX(-1rem);
  36. border-radius: 1.3125rem;
  37. background-color: #fff;
  38. &:dir(rtl) {
  39. transform: translateX(1rem);
  40. }
  41. .gin--dark-mode
  42. @media (prefers-reduced-motion: no-preference) {
  43. transition: transform 0.3s;
  44. }
  45. @media (forced-colors: active) {
  46. background-color: CanvasText;
  47. }
  48. }
  49. /* Disabled state: set cursor to not-allowed */
  50. &:disabled {
  51. cursor: not-allowed;
  52. }
  53. /* Hover state */
  54. &:hover {
  55. opacity: 0.9;
  56. box-shadow: 0 0 2px rgb(0, 0, 0, 0.2);
  57. }
  58. /* Hover/Focus state */
  59. &:active,
  60. &:focus {
  61. box-shadow:
  62. 0 0 0 1px var(--gin-color-focus-border),
  63. 0 0 0 4px var(--gin-color-focus);
  64. }
  65. /* Active state */
  66. &:checked {
  67. background-color: var(--gin-switch);
  68. .gin--dark-mode
  69. &::before {
  70. transform: translateX(1rem);
  71. background-color: #fff;
  72. &:dir(rtl) {
  73. transform: translateX(-1rem);
  74. }
  75. .gin--dark-mode
  76. .gin--high-contrast-mode
  77. @media (forced-colors: active) {
  78. padding-inline-start: var(--gin-spacing-xs);
  79. background-color: LinkText !important;
  80. }
  81. }
  82. @media (forced-colors: active) {
  83. &::after {
  84. transform: translateX(1rem);
  85. mask-image: var(--admin-icon-checked);
  86. mask-position: 2px 2px;
  87. &:dir(rtl) {
  88. transform: translateX(-1rem);
  89. }
  90. }
  91. }
  92. }
  93. /* Disabled state */
  94. &:disabled {
  95. opacity: 0.75;
  96. background-color: var(--gin-color-disabled);
  97. box-shadow: none;
  98. &::before {
  99. opacity: 0.6;
  100. background-color: #fff;
  101. }
  102. }
  103. @media (forced-colors: active) {
  104. border-width: 2px;
  105. }
  106. @media (forced-colors: active) {
  107. &::after {
  108. position: absolute;
  109. width: 100%;
  110. height: 100%;
  111. content: "";
  112. transform: translateX(-1rem);
  113. background-color: Canvas;
  114. mask-image: var(--admin-icon-toggle-unchecked);
  115. mask-size: 1rem 1rem;
  116. mask-position: 1.0625rem 2px;
  117. mask-repeat: no-repeat;
  118. &:dir(rtl) {
  119. transform: translateX(1rem);
  120. }
  121. @media (prefers-reduced-motion: no-preference) {
  122. transition: transform 0.3s;
  123. }
  124. }
  125. }
  126. }
  127. label {
  128. position: relative;
  129. z-index: 1;
  130. padding-block-end: 0;
  131. padding-inline-start: var(--gin-spacing-xxs);
  132. color: var(--gin-color-text);
  133. }
  134. }

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.