-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathToggleSwitch.css
More file actions
183 lines (159 loc) · 4.53 KB
/
ToggleSwitch.css
File metadata and controls
183 lines (159 loc) · 4.53 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* Webflow Site Variables Used:
* - --background-primary: Track background when unchecked
* - --background-secondary: Hover states
* - --text-primary: Label text color
* - --text-secondary: Description text color
* - --border-color: Track border
* - --accent-color: Track background when checked
* - --accent-text-color: Thumb color and icon color when checked
* - --border-radius: Track and thumb rounding
*/
/* Box sizing reset */
.wf-toggleswitch *,
.wf-toggleswitch *::before,
.wf-toggleswitch *::after {
box-sizing: border-box;
}
/* Root element - inherit Webflow typography + default padding */
.wf-toggleswitch {
font-family: inherit;
color: inherit;
line-height: inherit;
padding: 24px;
display: flex;
align-items: flex-start;
gap: 12px;
width: fit-content;
}
/* Size variants - custom properties */
.wf-toggleswitch--size-small {
--wf-toggleswitch-track-width: 36px;
--wf-toggleswitch-track-height: 20px;
--wf-toggleswitch-thumb-size: 16px;
--wf-toggleswitch-thumb-offset: 2px;
--wf-toggleswitch-label-size: 14px;
--wf-toggleswitch-description-size: 12px;
}
.wf-toggleswitch--size-medium {
--wf-toggleswitch-track-width: 44px;
--wf-toggleswitch-track-height: 24px;
--wf-toggleswitch-thumb-size: 20px;
--wf-toggleswitch-thumb-offset: 2px;
--wf-toggleswitch-label-size: 16px;
--wf-toggleswitch-description-size: 14px;
}
.wf-toggleswitch--size-large {
--wf-toggleswitch-track-width: 52px;
--wf-toggleswitch-track-height: 28px;
--wf-toggleswitch-thumb-size: 24px;
--wf-toggleswitch-thumb-offset: 2px;
--wf-toggleswitch-label-size: 18px;
--wf-toggleswitch-description-size: 16px;
}
/* Label position variants */
.wf-toggleswitch--label-left {
flex-direction: row;
}
.wf-toggleswitch--label-right {
flex-direction: row-reverse;
}
/* Label wrapper */
.wf-toggleswitch-label-wrapper {
display: flex;
flex-direction: column;
gap: 4px;
}
/* Label */
.wf-toggleswitch-label {
font-size: var(--wf-toggleswitch-label-size);
font-weight: 500;
color: var(--text-primary, #1a1a1a);
line-height: 1.4;
}
/* Description */
.wf-toggleswitch-description {
font-size: var(--wf-toggleswitch-description-size);
color: var(--text-secondary, #737373);
line-height: 1.4;
}
/* Button */
.wf-toggleswitch-button {
background: transparent;
border: none;
padding: 0;
cursor: pointer;
flex-shrink: 0;
position: relative;
outline: none;
}
.wf-toggleswitch-button:focus-visible {
outline: 2px solid var(--accent-color, #1a1a1a);
outline-offset: 2px;
border-radius: calc(var(--border-radius, 8px) * 2);
}
/* Track */
.wf-toggleswitch-track {
display: block;
width: var(--wf-toggleswitch-track-width);
height: var(--wf-toggleswitch-track-height);
background: var(--background-primary, #ffffff);
border: 1px solid var(--border-color, #e5e5e5);
border-radius: calc(var(--wf-toggleswitch-track-height) / 2);
position: relative;
transition: background-color 0.2s, border-color 0.2s;
}
.wf-toggleswitch-button:hover .wf-toggleswitch-track {
background: var(--background-secondary, #f5f5f5);
}
.wf-toggleswitch--checked .wf-toggleswitch-track {
background: var(--accent-color, #1a1a1a);
border-color: var(--accent-color, #1a1a1a);
}
.wf-toggleswitch--checked .wf-toggleswitch-button:hover .wf-toggleswitch-track {
background: var(--accent-color, #1a1a1a);
opacity: 0.9;
}
/* Thumb */
.wf-toggleswitch-thumb {
display: flex;
align-items: center;
justify-content: center;
width: var(--wf-toggleswitch-thumb-size);
height: var(--wf-toggleswitch-thumb-size);
background: var(--text-primary, #1a1a1a);
border-radius: 50%;
position: absolute;
top: var(--wf-toggleswitch-thumb-offset);
left: var(--wf-toggleswitch-thumb-offset);
transition: transform 0.2s, background-color 0.2s;
}
.wf-toggleswitch--checked .wf-toggleswitch-thumb {
transform: translateX(calc(var(--wf-toggleswitch-track-width) - var(--wf-toggleswitch-thumb-size) - (var(--wf-toggleswitch-thumb-offset) * 2)));
background: var(--accent-text-color, #ffffff);
}
/* Icon */
.wf-toggleswitch-icon {
display: flex;
align-items: center;
justify-content: center;
color: var(--accent-text-color, #ffffff);
}
.wf-toggleswitch--checked .wf-toggleswitch-icon {
color: var(--accent-color, #1a1a1a);
}
.wf-toggleswitch-icon svg {
width: 12px;
height: 12px;
}
/* Disabled state */
.wf-toggleswitch--disabled {
opacity: 0.5;
pointer-events: none;
}
.wf-toggleswitch--disabled .wf-toggleswitch-button {
cursor: not-allowed;
}
.wf-toggleswitch--disabled .wf-toggleswitch-label {
color: var(--text-secondary, #737373);
}