HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Theme switch</title> <script src="https://unpkg.com/@mahozad/theme-switch"></script> <link rel="stylesheet" href="styles.css"> </head> <body> <theme-switch></theme-switch> </body> </html>
CSS
html { background: #fff1a4; /* Adopted from Bootstrap website: https://getbootstrap.com */ background-image: radial-gradient(ellipse at top left, #ddfd0d80, transparent 50%), radial-gradient(ellipse at center left, #d6338480, transparent 50%); transition: background 300ms ease; } html[data-theme="dark"] { background: #a8d8ff; background-image: radial-gradient(ellipse at top left, #0d6efd80, transparent 50%), radial-gradient(ellipse at center left, #d6338480, transparent 50%); } theme-switch { --theme-switch-icon-color: #000d; width: 256px; }
JavaScript
/* No JavaScript code used */