-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch.html
More file actions
110 lines (94 loc) · 2.2 KB
/
switch.html
File metadata and controls
110 lines (94 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Night/Light Mode Toggle</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<style>
:root {
--background-light: #f5f5f7;
--text-light: #333333;
--background-dark: #1c1c1e;
--text-dark: #ffffff;
--toggle-light: #FD632F;
--toggle-dark: #34C759;
}
body {
font-family: 'Inter', sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: var(--background-light);
color: var(--text-light);
transition: background-color 0.3s ease, color 0.3s ease;
}
body.dark-mode {
background-color: var(--background-dark);
color: var(--text-dark);
}
.cont {
text-align: center;
}
.toggle {
position: relative;
display: inline-block;
}
.toggle__input {
display: none;
}
.toggle__label {
display: block;
width: 60px;
height: 30px;
background-color: var(--toggle-light);
border-radius: 99px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.dark-mode .toggle__label {
background-color: var(--toggle-dark);
}
.toggle__input:checked + .toggle__label::after {
left: 32px;
}
.toggle__label::after {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 26px;
height: 26px;
background-color: #ffffff;
border-radius: 50%;
transition: left 0.3s ease;
}
</style>
</head>
<body>
<div class="cont">
<div class="toggle">
<input type="checkbox" id="mode-toggle" class="toggle__input">
<label for="mode-toggle" class="toggle__label"></label>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
@page "/toggle-switch"
<h3>Toggle Switch</h3>
<div>
<label class="switch">
<input type="checkbox" @bind="IsToggled">
<span class="slider"></span>
</label>
<span class="switch-label">@ToggleLabel</span>
</div>
@code {
private bool IsToggled { get; set; } = false;
private string ToggleLabel => IsToggled ? "On" : "Off";
}