Skip to content

Commit

Permalink
Merge pull request #853 from Giftzzz/patch-1
Browse files Browse the repository at this point in the history
Create dark.html
  • Loading branch information
Ayushparikh-code authored Oct 29, 2024
2 parents 69bc5c0 + 58c862a commit 9911804
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions dark.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dark/Light Theme Toggle</title>
<style>
/* Default Light Theme */
:root {
--background-color: #ffffff;
--text-color: #000000;
}

/* Dark Theme */
.dark-mode {
--background-color: #121212;
--text-color: #ffffff;
}

body {
background-color: var(--background-color);
color: var(--text-color);
font-family: Arial, sans-serif;
transition: background-color 0.3s, color 0.3s;
}

.theme-toggle-btn {
position: absolute;
top: 20px;
right: 20px;
padding: 10px 20px;
cursor: pointer;
background-color: var(--text-color);
color: var(--background-color);
border: none;
border-radius: 5px;
transition: background-color 0.3s, color 0.3s;
}
</style>
</head>
<body>

<h1>Dark/Light Theme Toggle</h1>
<p>This is an example of switching between dark and light modes using a toggle button.</p>
<button class="theme-toggle-btn" id="theme-toggle">Toggle Theme</button>

<script>
const toggleButton = document.getElementById('theme-toggle');
const body = document.body;

toggleButton.addEventListener('click', () => {
body.classList.toggle('dark-mode');
updateButtonText();
});

function updateButtonText() {
if (body.classList.contains('dark-mode')) {
toggleButton.textContent = 'Switch to Light Mode';
} else {
toggleButton.textContent = 'Switch to Dark Mode';
}
}

// Initialize button text
updateButtonText();
</script>

</body>
</html>

0 comments on commit 9911804

Please sign in to comment.