Skip to content

Commit 85c64f5

Browse files
committed
Display: Fix styles for primevue toggle switch
1 parent 4075aea commit 85c64f5

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed
Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
1-
.p-inputswitch {
2-
@apply align-middle h-4 w-8;
1+
.p-toggleswitch {
2+
@apply inline-block w-8 h-4;
33

4-
.p-inputswitch-input {
5-
@apply appearance-none absolute top-0 left-0 w-full h-full p-0 m-0 opacity-0 z-[1] outline-0 outline-none rounded-full;
4+
&-input {
5+
@apply cursor-pointer appearance-none absolute top-0 start-0 w-full h-full p-0 m-0 opacity-0 z-[1] outline-0 outline-none rounded-full;
66
}
77

8-
.p-inputswitch-slider {
9-
@apply bg-gray-30 rounded-full transition-none outline-transparent
10-
before:bg-white before:duration-200 before:h-3 before:left-0.5 before:-mt-1.5 before:rounded-full before:w-3;
11-
}
8+
&-slider {
9+
@apply cursor-pointer w-full h-full border-0 border-none bg-gray-30 transition rounded-full drop-shadow-none;
1210

13-
&.p-highlight .p-inputswitch-slider {
14-
@apply bg-secondary
15-
before:bg-white before:translate-x-4;
16-
}
11+
.p-toggleswitch.p-toggleswitch-checked & {
12+
@apply bg-secondary;
13+
}
1714

18-
&:not(.p-disabled) {
19-
&:has(.p-inputswitch-input:hover) {
20-
.p-inputswitch-slider {
21-
@apply bg-gray-30;
22-
}
15+
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:hover) & {
16+
@apply bg-gray-50;
17+
}
2318

24-
&.p-highlight .p-inputswitch-slider {
25-
@apply bg-secondary;
26-
}
19+
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:hover).p-toggleswitch-checked & {
20+
@apply bg-secondary;
2721
}
2822

29-
&:has(.p-inputswitch-input:focus-visible) .p-inputswitch-slider {
30-
@apply outline-0 outline-none outline-offset-0 shadow-lg;
23+
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:focus-visible) & {
24+
@apply outline-none outline-0;
3125
}
32-
}
3326

34-
&.p-invalid > .p-inputswitch-slider {
35-
@apply border-error;
27+
.p-toggleswitch.p-disabled & { }
28+
29+
.p-toggleswitch.p-invalid > & {
30+
@apply border border-solid border-danger;
31+
}
3632
}
37-
}
3833

39-
.p-inputswitch-input {
40-
@apply cursor-pointer;
41-
}
34+
&-handle {
35+
@apply absolute flex justify-center items-center bg-white text-gray-90 h-3 w-3 top-0.5 left-0.5 rounded-full transition-colors;
4236

43-
.p-inputswitch-slider {
44-
@apply absolute cursor-pointer top-0 left-0 right-0 bottom-0 border border-transparent
45-
before:absolute before:content-[""] before:top-1/2;
46-
}
37+
.p-toggleswitch.p-toggleswitch-checked & {
38+
@apply translate-x-4;
39+
}
40+
41+
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:hover) & { }
42+
43+
.p-toggleswitch.p-disabled & { }
4744

45+
.p-toggleswitch:not(.p-disabled):has(.p-toggleswitch-input:hover).p-toggleswitch-checked & { }
46+
}
47+
48+
&.p-disabled {
49+
@apply opacity-100;
50+
}
51+
}

0 commit comments

Comments
 (0)