Slider

Online
                
                
                    
<div>
    <label class="stg-switch">
        <input type="checkbox" name="aktuelles_video_online" class="stg-slider-checkbox" onclick="updateStatus(this,'stg-status-label')" checked>
        <span class="stg-slider">
            <img class="stg-check_img stg-green" src="./images/icon_check_green.png" alt="Icon Check">
            <img class="stg-check_img stg-gray" src="./images/icon_check_grey.png" alt="Icon Uncheck">
        </span>
    </label>
    <span class="stg-status-label online">Online</span>
</div>
                
            
                
                
                    
.stg-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.stg-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--grau_3);
  transition: .4s;
  border-radius: 22px;
}

.stg-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 1px;
  top: 1px;
  bottom: 2px;
  background-color: white;
  border: 1px solid var(--grau_3);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .stg-slider::before {
  border: 1px solid var(--gruen);
}

/* Grauer Haken angezeigt, wenn nicht checked */
input:not(:checked) + .stg-slider .stg-check_img.stg-gray { 
  opacity: 1;
}

/* Gruener Haken angezeigt, wenn checked */
input:checked + .stg-slider .stg-check_img.stg-green { 
  opacity: 1;
}

input:checked + .stg-slider {
  background-color: var(--gruen);
}

input:checked + .stg-slider:before,
input:checked + .stg-slider .stg-check_img {
  transform: translateX(18px);
}

.stg-check_img {
  position: absolute;
  left: 6px;
  top: 6px;
  width: auto;
  height: auto;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.2s;
  opacity: 0;
}
                
            
                
                
                    
function updateStatus(checkbox, statusLabel) {
    var labelSpan = checkbox.closest('label').nextElementSibling;
    if(labelSpan && labelSpan.classList.contains(statusLabel)) {
        labelSpan.textContent = checkbox.checked ? 'Online' : 'Offline';
        labelSpan.classList.toggle("offline", !checkbox.checked);
        labelSpan.classList.toggle("online", checkbox.checked);
    }
}
                
            
#slider button #slider checkbox #toggle #schalter #status toggle #switch button