Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make scrollbar always visible in angular material?

So currently, I'm using angular material and its default scroll (But I think it is perfect scrollbar) to use as a scroll design to my scroll bar. But the scroll is only showing if the users try to scroll the page/div. I tried to read the scrolling api of the Angular Material but there's no attribute that I can use in here. And I do already put the overflow-y: scroll on the css of course. Any idea? Thanks!

like image 585
Rich Avatar asked Feb 13 '19 06:02

Rich


1 Answers

So I found a work around, I need to include pseudo class to my CSS

::-webkit-scrollbar {
  -webkit-appearance: none;
  width: 7px;
}
::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background-color: rgba(0, 0, 0, .5);
  -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
}

And if you need it to a specific element or container

.selectionTable::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 7px;
}

.selectionTable::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: rgba(0, 0, 0, .5);
    -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
}

Reference:

Making the main scrollbar always visible

Apply webkit scrollbar style to specified element

like image 139
Rich Avatar answered Nov 13 '22 10:11

Rich