Skip to content

Commit 31ffd17

Browse files
authored
fix: broken scrollbar color in safari (#111)
new safari added the scrollbar-color property but as it also support -webkit-scrollbar they both collide and somehow break the styling
1 parent 68318cf commit 31ffd17

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/components/scroll/Scroll.css.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ export const Scroll = recipe({
2323
width: "100%",
2424
height: "100%",
2525
overflow: "hidden",
26-
scrollbarColor: "transparent transparent",
26+
27+
"@supports": {
28+
"not selector(::-webkit-scrollbar)": {
29+
scrollbarColor: "transparent transparent",
30+
},
31+
},
2732

2833
selectors: {
2934
"&::-webkit-scrollbar-thumb": {
@@ -54,7 +59,11 @@ export const Scroll = recipe({
5459
},
5560
visibility: {
5661
Always: {
57-
scrollbarColor: `${ScrollThumbColor} ${ScrollTrackColor}`,
62+
"@supports": {
63+
"not selector(::-webkit-scrollbar)": {
64+
scrollbarColor: `${ScrollThumbColor} ${ScrollTrackColor}`,
65+
},
66+
},
5867
selectors: {
5968
"&::-webkit-scrollbar-thumb": {
6069
backgroundColor: ScrollThumbColor,
@@ -65,10 +74,16 @@ export const Scroll = recipe({
6574
},
6675
},
6776
Hover: {
68-
selectors: {
69-
"&:hover": {
70-
scrollbarColor: `${ScrollThumbColor} ${ScrollTrackColor}`,
77+
"@supports": {
78+
"not selector(::-webkit-scrollbar)": {
79+
selectors: {
80+
"&:hover": {
81+
scrollbarColor: `${ScrollThumbColor} ${ScrollTrackColor}`,
82+
},
83+
},
7184
},
85+
},
86+
selectors: {
7287
"&:hover::-webkit-scrollbar-thumb": {
7388
backgroundColor: ScrollThumbColor,
7489
},
@@ -88,7 +103,7 @@ export const Scroll = recipe({
88103
size: {
89104
"0": {
90105
"@supports": {
91-
"(scrollbar-color: transparent transparent)": {
106+
"not selector(::-webkit-scrollbar)": {
92107
scrollbarWidth: "none",
93108
},
94109
},
@@ -100,9 +115,7 @@ export const Scroll = recipe({
100115
},
101116
"300": {
102117
"@supports": {
103-
"(scrollbar-color: transparent transparent)": {
104-
// only apply scrollbarWidth if scrollbar-color is supported,
105-
// otherwise it breaks the colors in some browser like safari.
118+
"not selector(::-webkit-scrollbar)": {
106119
scrollbarWidth: "thin",
107120
},
108121
},
@@ -119,7 +132,7 @@ export const Scroll = recipe({
119132
},
120133
"400": {
121134
"@supports": {
122-
"(scrollbar-color: transparent transparent)": {
135+
"not selector(::-webkit-scrollbar)": {
123136
scrollbarWidth: "auto",
124137
},
125138
},

0 commit comments

Comments
 (0)