Skip to content

Commit 6f9949a

Browse files
committed
Add min touch size for control switch
1 parent c78cfb4 commit 6f9949a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/components/ha-control-switch.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export class HaControlSwitch extends LitElement {
196196
--control-switch-background-opacity: 0.2;
197197
--control-switch-hover-background-opacity: 0.4;
198198
--control-switch-thickness: 40px;
199+
--control-switch-min-touch-size: 40px;
199200
--control-switch-border-radius: var(--ha-border-radius-lg);
200201
--control-switch-padding: 4px;
201202
--mdc-icon-size: 20px;
@@ -219,21 +220,35 @@ export class HaControlSwitch extends LitElement {
219220
width: 100%;
220221
border-radius: var(--control-switch-border-radius);
221222
outline: none;
222-
overflow: hidden;
223223
padding: var(--control-switch-padding);
224224
display: flex;
225225
cursor: pointer;
226226
}
227+
.switch::before {
228+
content: "";
229+
position: absolute;
230+
top: 50%;
231+
left: 50%;
232+
transform: translate(-50%, -50%);
233+
width: 100%;
234+
height: 100%;
235+
min-width: var(--control-switch-min-touch-size);
236+
min-height: var(--control-switch-min-touch-size);
237+
}
227238
.switch[disabled] {
228239
opacity: 0.5;
229240
cursor: not-allowed;
230241
}
242+
.switch[disabled]::before {
243+
pointer-events: none;
244+
}
231245
.switch .background {
232246
position: absolute;
233247
top: 0;
234248
left: 0;
235249
height: 100%;
236250
width: 100%;
251+
border-radius: inherit;
237252
background-color: var(--control-switch-off-color);
238253
transition: background-color 180ms ease-in-out;
239254
opacity: var(--control-switch-background-opacity);

0 commit comments

Comments
 (0)