question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot style scrollbar on chrome

See original GitHub issue

Bug Report

Ionic version:

[x] 4.x

Current behavior:

CSS cannot be applied to style component overflow scrollbar appearance.

This leads to scrollbars for PWAs that cannot be styled to match the theme of the application:

image

Expected behavior: We should be able to style scrollbars using CSS. https://css-tricks.com/custom-scrollbars-in-webkit/

Steps to reproduce: Just display any starter app in a web browser (not in mobile emulation mode), and resize the window to cause overflow. The scrollbar will appear and cannot be re-styled.

Related code:

The following CSS should style ALL scrollbars in the application. I’ve tried a variety of permutations of this to no avail.

  :root * {
    &::-webkit-scrollbar {
      width: 12px;
    }

    &::-webkit-scrollbar-track {
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
      -webkit-border-radius: 10px;
      border-radius: 10px;
    }

    &::-webkit-scrollbar-thumb {
      -webkit-border-radius: 10px;
      border-radius: 10px;
      background: rgba(255, 0, 0, 0.8);
      -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
    }

    &::-webkit-scrollbar-thumb:window-inactive {
      background: rgba(255, 0, 0, 0.4);
    }
  }

https://stackblitz.com/edit/ionic-v4-z4czrb?file=src%2Fglobal.scss

Other information: This issue has been alluded to or reported in the incorrect place a number of times. Here are a few:

https://github.com/ionic-team/ionic-v3/issues/737 https://github.com/ionic-team/ionic/issues/17608

Ionic info:

Lincolns-MacBook-Pro-2:topdecked-unified lincoln$ ionic info

Ionic:

   ionic (Ionic CLI)             : 4.10.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.2
   @angular-devkit/build-angular : 0.13.1
   @angular-devkit/schematics    : 7.3.1
   @angular/cli                  : 7.3.1
   @ionic/angular-toolkit        : 1.3.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   Android SDK Tools : 26.1.1 (/usr/local/share/android-sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v11.2.0 (/usr/local/Cellar/node/11.2.0/bin/node)
   npm               : 6.4.1
   OS                : macOS Mojave
   Xcode             : Xcode 10.1 Build version 10B61


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:30 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
liamdebeasicommented, Feb 18, 2020

Thanks for the issue! After discussion with the team, we have decided not to support this functionality.

The CSS that is used to style scrollbars is non-standard and not cross browser compatible. MDN says that it should not be used in production sites: https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar

image

Since this CSS is non-standard, its behavior may change unexpectedly in the future or be removed entirely. In 2019 we started to see this happen with the introduction of iOS 13. Scrollbar styling used to work in certain contexts on Safari, but as of today it no longer works.

Additionally, because this CSS is not cross browser compatible, it will not work in non-WebKit browsers such as Firefox.

For developers that still would like to use custom scrollbars, I have created a CodePen with a workaround: https://codepen.io/liamdebeasi/pen/QWbEbpO. Please note that this code may break in the future due to the reasons I listed previously.

3reactions
loopezzcommented, Dec 18, 2019

Any progress on this issue, Ionic?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styling ::-webkit-scrollbar-track not working - Stack Overflow
I just checked scrolling on another machine (same OS and same Chrome version), and the scrollbar disappears when not being scrolled, as expected ......
Read more >
::-webkit-scrollbar - CSS: Cascading Style Sheets | MDN
The ::-webkit-scrollbar CSS pseudo-element affects the style of an element's scrollbar when it has overflow:scroll; set.
Read more >
How to Customize the Scrollbar in Google Chrome With ...
To get Custom Scrollbars, open the extension on the Chrome Web Store within Google Chrome. Click the + Add to Chrome button on...
Read more >
scrollbar - CSS-Tricks
Setting -webkit-scrollbar styles is a good way to force your webpage to show horizontal or vertical scrollbars on versions of Mac OS newer...
Read more >
Custom Scrollbars In CSS - Ahmad Shadeed
We can't add shadows, gradients, rounded edges, or anything like that. What we're allowed to customize is the colors only. Scrollbar gutter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found