Interrupteurs · HTML / CSS
Interactive Dark Mode Switch
Par Design Engineers · 21st.dev · MIT
Survolez ou cliquez pour essayer. Aucun formulaire ne transmet de données.
<!--
MIT License Copyright (c) 2026 Author
Author: Design Engineers
Source: https://21st.dev/r/dark-mode-switch
Revision: main
-->
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interactive Dark Mode Switch</title><style>html{height:100%;background:#e9e9ef}body{margin:0;min-height:100%;display:grid;place-items:center;padding:24px;box-sizing:border-box;font-family:Arial,sans-serif}#clicks-preview-root{display:flex;align-items:center;justify-content:center;max-width:100%;min-width:0}*{box-sizing:border-box}.switch-container {
display: inline-flex;
align-items: center;
gap: 14px;
cursor: pointer;
font-family: system-ui, sans-serif;
color: #e2e8f0;
font-size: 14px;
font-weight: 500;
}
.switch-input {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.switch-slider {
position: relative;
display: inline-block;
width: 52px;
height: 28px;
background: #1e2230;
border-radius: 9999px;
border: 1px solid rgba(255, 255, 255, 0.12);
transition: background 0.3s, border-color 0.3s;
}
.switch-input:checked + .switch-slider {
background: #6366f1;
border-color: #818cf8;
}
.switch-knob {
position: absolute;
top: 2px;
left: 2px;
width: 22px;
height: 22px;
border-radius: 50%;
background: #ffffff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.switch-input:checked + .switch-slider .switch-knob {
transform: translateX(24px);
}
@media(max-height:350px){#clicks-preview-root{transform:scale(.8);transform-origin:center}}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}</style></head><body><div id="clicks-preview-root"><label class="switch-container">
<input type="checkbox" class="switch-input" checked="">
<span class="switch-slider">
<span class="switch-knob"></span>
</span>
<span class="switch-label">Dark Theme Active</span>
</label></div></body></html>Télécharger le HTML ↓Auteur, source & licence
Le code d’origine est conservé avec sa révision. L’aperçu utilise un cadre de présentation Clicks et bloque les scripts et ressources externes.
Source originale ↗21st.dev · Révision main
Importé le 2026-10-17. La date d’import n’est pas la date de création.
Lire la licence MIT
MIT License Copyright (c) 2026 Author