Illustration Toggle Switch by codepeek
Zoom
Saved
1 line⌘Z Undo
1<!--2 Author: @codepeek3 License: MIT4 Tags: #illustration #light #playful #spring #toggle5-->6<label class="mbx">7 <input class="mbx__in" type="checkbox" role="switch">8 <span class="mbx__scene" aria-hidden="true">9 <span class="mbx__box">10 </span>11 <span class="mbx__flag">12 </span>13 <span class="mbx__post">14 </span>15 </span>16 <span class="mbx__text">17 <span class="mbx__name">Outgoing mail</span>18 <span class="mbx__state" aria-hidden="true">19 </span>20 </span>21</label>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!--
Author: @codepeek
License: MIT
Tags: #illustration #light #playful #spring #toggle
-->
<label class="mbx">
<input class="mbx__in" type="checkbox" role="switch">
<span class="mbx__scene" aria-hidden="true">
<span class="mbx__box">
</span>
<span class="mbx__flag">
</span>
<span class="mbx__post">
</span>
</span>
<span class="mbx__text">
<span class="mbx__name">Outgoing mail</span>
<span class="mbx__state" aria-hidden="true">
</span>
</span>
</label>1/* * Author: @codepeek * License: MIT * Tags: #illustration #light #playful #spring #toggle */2.mbx {3 position: relative;4 display: inline-flex;5 align-items: center;6 gap: 18px;7 cursor: pointer;8 font-family: Inter,system-ui,sans-serif;9 color: #2a272210}11.mbx__in {12 position: absolute;13 top: 0;14 left: 0;15 width: 1px;16 height: 1px;17 margin: 0;18 opacity: 019}20.mbx__scene {21 position: relative;22 width: 140px;23 height: 130px24}25.mbx__box {26 position: absolute;27 z-index: 1;28 left: 8px;29 top: 40px;30 width: 112px;31 height: 56px;32 border-radius: 28px 28px 4px 4px;33 background: repeating-linear-gradient(90deg,transparent 0 16px,rgba(42,39,34,.08) 16px 18px),linear-gradient(#fbf8f2,#cfc5b2);34 box-shadow: inset 0 2px 0 #fff,inset -3px 0 0 rgba(0,0,0,.06),0 0 0 1.5px #2a2722,0 10px 14px -10px rgba(42,39,34,.6)35}36.mbx__box::before {37 content: "";38 position: absolute;39 left: 0;40 top: 0;41 bottom: 0;42 width: 10px;43 border-radius: 28px 0 0 4px;44 background: linear-gradient(#e1d9c9,#b5a88f);45 box-shadow: 1px 0 0 #2a272246}47.mbx__box::after {48 content: "";49 position: absolute;50 left: 14px;51 top: 44%;52 width: 8px;53 height: 4px;54 border-radius: 2px;55 background: #2a272256}57.mbx__post {58 position: absolute;59 left: 50px;60 top: 94px;61 width: 16px;62 height: 36px;63 background: linear-gradient(90deg,#4a2e18,#7a4e2c 50%,#4a2e18);64 box-shadow: 0 0 0 1.5px #2a272265}66.mbx__flag {67 position: absolute;68 z-index: 2;69 left: 100px;70 top: 34px;71 width: 5px;72 height: 40px;73 border-radius: 2px;74 background: #2a2722;75 transform-origin: 50% 100%;76 rotate: -90deg;77 transition: rotate .55s cubic-bezier(.4,1.9,.5,1)78}79.mbx__flag::before {80 content: "";81 position: absolute;82 top: 0;83 left: 4px;84 width: 20px;85 height: 13px;86 border-radius: 0 3px 3px 0;87 background: linear-gradient(#ff8a3d,#ff6a13 60%,#c44d07);88 box-shadow: 0 0 0 1.5px #2a272289}90.mbx__flag::after {91 content: "";92 position: absolute;93 bottom: -3px;94 left: -2px;95 width: 9px;96 height: 9px;97 border-radius: 50%;98 background: #e1ddd5;99 box-shadow: 0 0 0 1.5px #2a2722100}101.mbx__text {102 display: grid;103 gap: 4px104}105.mbx__name {106 font-size: 14px;107 font-weight: 600108}109.mbx__state {110 font-family: ui-monospace,SFMono-Regular,Menlo,monospace;111 font-size: 10px;112 letter-spacing: .16em;113 color: #8d8a84114}115.mbx__state::after {116 content: "NOTHING TO SEND"117}118.mbx__in:checked ~ .mbx__scene .mbx__flag {119 rotate: 0deg120}121.mbx__in:checked ~ .mbx__text .mbx__state {122 color: #d4520a123}124.mbx__in:checked ~ .mbx__text .mbx__state::after {125 content: "FLAG UP \00b7 PICKUP"126}127.mbx__in:focus-visible ~ .mbx__scene {128 outline: 2px solid #ff6a13;129 outline-offset: 2px;130 border-radius: 8px131}132@media (prefers-reduced-motion:reduce) {133 .mbx__flag {134 transition: none135 }136}
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* * Author: @codepeek * License: MIT * Tags: #illustration #light #playful #spring #toggle */
.mbx {
position: relative;
display: inline-flex;
align-items: center;
gap: 18px;
cursor: pointer;
font-family: Inter,system-ui,sans-serif;
color: #2a2722
}
.mbx__in {
position: absolute;
top: 0;
left: 0;
width: 1px;
height: 1px;
margin: 0;
opacity: 0
}
.mbx__scene {
position: relative;
width: 140px;
height: 130px
}
.mbx__box {
position: absolute;
z-index: 1;
left: 8px;
top: 40px;
width: 112px;
height: 56px;
border-radius: 28px 28px 4px 4px;
background: repeating-linear-gradient(90deg,transparent 0 16px,rgba(42,39,34,.08) 16px 18px),linear-gradient(#fbf8f2,#cfc5b2);
box-shadow: inset 0 2px 0 #fff,inset -3px 0 0 rgba(0,0,0,.06),0 0 0 1.5px #2a2722,0 10px 14px -10px rgba(42,39,34,.6)
}
.mbx__box::before {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 10px;
border-radius: 28px 0 0 4px;
background: linear-gradient(#e1d9c9,#b5a88f);
box-shadow: 1px 0 0 #2a2722
}
.mbx__box::after {
content: "";
position: absolute;
left: 14px;
top: 44%;
width: 8px;
height: 4px;
border-radius: 2px;
background: #2a2722
}
.mbx__post {
position: absolute;
left: 50px;
top: 94px;
width: 16px;
height: 36px;
background: linear-gradient(90deg,#4a2e18,#7a4e2c 50%,#4a2e18);
box-shadow: 0 0 0 1.5px #2a2722
}
.mbx__flag {
position: absolute;
z-index: 2;
left: 100px;
top: 34px;
width: 5px;
height: 40px;
border-radius: 2px;
background: #2a2722;
transform-origin: 50% 100%;
rotate: -90deg;
transition: rotate .55s cubic-bezier(.4,1.9,.5,1)
}
.mbx__flag::before {
content: "";
position: absolute;
top: 0;
left: 4px;
width: 20px;
height: 13px;
border-radius: 0 3px 3px 0;
background: linear-gradient(#ff8a3d,#ff6a13 60%,#c44d07);
box-shadow: 0 0 0 1.5px #2a2722
}
.mbx__flag::after {
content: "";
position: absolute;
bottom: -3px;
left: -2px;
width: 9px;
height: 9px;
border-radius: 50%;
background: #e1ddd5;
box-shadow: 0 0 0 1.5px #2a2722
}
.mbx__text {
display: grid;
gap: 4px
}
.mbx__name {
font-size: 14px;
font-weight: 600
}
.mbx__state {
font-family: ui-monospace,SFMono-Regular,Menlo,monospace;
font-size: 10px;
letter-spacing: .16em;
color: #8d8a84
}
.mbx__state::after {
content: "NOTHING TO SEND"
}
.mbx__in:checked ~ .mbx__scene .mbx__flag {
rotate: 0deg
}
.mbx__in:checked ~ .mbx__text .mbx__state {
color: #d4520a
}
.mbx__in:checked ~ .mbx__text .mbx__state::after {
content: "FLAG UP \00b7 PICKUP"
}
.mbx__in:focus-visible ~ .mbx__scene {
outline: 2px solid #ff6a13;
outline-offset: 2px;
border-radius: 8px
}
@media (prefers-reduced-motion:reduce) {
.mbx__flag {
transition: none
}
}Changes made here are only a live preview and will not be saved.
Save to GitHub
GitHub opens a new file in your repository with this element filled in. Review it there and press Commit changes. Nothing is sent from codepeek and no GitHub access is needed.
◉ 2 views
Build it with AIA ready prompt with the code, the credit and how to adapt it to your project.
A ribbed bone mailbox on a timber post with a signal-orange flag that springs upright when there is outgoing mail waiting for pickup.
Choose where to donate
Select a platform to continue.
Community
Comments 0
Code copied
SUPPORT THE CREATOR
Would you like to donate to the creator to help them keep creating content?
You need to sign in before you can write a comment.