Skip to content

Commit 1e5ff27

Browse files
authored
Fixed scrollbar colors for dark mode (#4969)
* Fixed scrollbar colors for dark mode Uses the `euiScrollBar()` mixin at the `html` level and adding a 3rd parameter for `$size` with the default being `thin` (as it were) and allowing `thick` to maintain the larger size for the overall page. Caveat: This could mean Firefox instances of scrolling containers are no longer “thin” if they don’t use the mixin.
1 parent 004ac12 commit 1e5ff27

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## [`master`](https://github.com/elastic/eui/tree/master)
22

3-
No public interface changes since `36.0.0`.
3+
- Fixed color of `html` scrollbar in dark mode ([#4969](https://github.com/elastic/eui/pull/4969))
44

55
## [`36.0.0`](https://github.com/elastic/eui/tree/v36.0.0)
66

src/global_styling/mixins/_helpers.scss

+13-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
}
2525

2626
// Set scroll bar appearance on Chrome (and firefox).
27-
@mixin euiScrollBar($thumbColor: $euiColorDarkShade, $trackBackgroundColor: transparent) {
27+
@mixin euiScrollBar($thumbColor: $euiColorDarkShade, $trackBackgroundColor: transparent, $size: 'thin') {
2828
// Firefox's scrollbar coloring cascades, but the sizing does not,
2929
// so it's being added to this mixin for allowing support wherever custom scrollbars are
3030
// sass-lint:disable-block no-misspelled-properties
31-
scrollbar-width: thin;
31+
scrollbar-color: transparentize($thumbColor, .5) $trackBackgroundColor; // Firefox support
32+
33+
@if ($size == 'thin') {
34+
scrollbar-width: thin;
35+
}
3236

3337
// sass-lint:disable-block no-vendor-prefixes
3438
&::-webkit-scrollbar {
@@ -38,8 +42,14 @@
3842

3943
&::-webkit-scrollbar-thumb {
4044
background-color: transparentize($thumbColor, .5);
41-
border: $euiScrollBarCorner solid $trackBackgroundColor;
4245
background-clip: content-box;
46+
border-radius: $euiScrollBar;
47+
48+
@if ($size == 'thin') {
49+
border: $euiScrollBarCornerThin solid $trackBackgroundColor;
50+
} @else {
51+
border: $euiScrollBarCorner solid $trackBackgroundColor;
52+
}
4353
}
4454

4555
&::-webkit-scrollbar-corner,

src/global_styling/mixins/_shadow.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
}
8888

8989
@mixin euiOverflowShadow($direction: 'y', $side: 'both') {
90-
$hideHeight: $euiScrollBarCorner * 1.25;
90+
$hideHeight: $euiScrollBarCornerThin * 1.25;
9191
$gradient: null;
9292
$gradientStart:
9393
transparentize(red, .9) 0%,
+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// Firefox's scrollbar coloring cascades throughout which is why it's set at the html level
2-
// However, the width sizing is not, but this has been added to the euiScrollBar mixin as well
1+
// Declaring the top level scrollbar colors to match the theme also requires setting the sizes on Chrome
2+
// so that it knows to use custom styles. Therefore, we just reuse the same scrollbar mixin with `thick` size.
33

44
html {
5-
// sass-lint:disable-block no-misspelled-properties
6-
scrollbar-width: thin;
7-
scrollbar-color: transparentize($euiColorDarkShade, .5) transparent; // Firefox support
5+
@include euiScrollBar($euiColorDarkShade, shadeOrTint($euiPageBackgroundColor, 3%, 7%), 'thick');
86
}

src/global_styling/variables/_size.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ $euiSizeXXL: $euiSize * 2.5 !default;
1010
$euiButtonMinWidth: $euiSize * 7 !default;
1111

1212
$euiScrollBar: $euiSize !default;
13-
$euiScrollBarCorner: $euiSizeS * .75 !default;
13+
// Corner sizes are used as an inset border and therefore a smaller corner size means a larger thumb
14+
$euiScrollBarCorner: $euiSizeXS !default;
15+
$euiScrollBarCornerThin: $euiSizeS * .75 !default;

0 commit comments

Comments
 (0)