ion-modal has a default scrollbar that appears if the content overflows. I want to style the scrollbar.
I can style the scrollbar in the application using ::-webkit-scrollbar, ::-webkit-scrollbar-track and ::-webkit-scrollbar-thumb, but it doesn't seem to work in modal. I tried applying these elements to multiple components inside the modal, such as ion-content::-webkit-scrollbar, but it doesn't work.
P粉6701076612024-01-05 09:42:15
Here's the general way to style scrollbars within Ionic mode in Ionic 6.
Tag as shown below
<ion-content> //modal content goes here </ion-content>
Then add the following css of the scrollbar in the global css file
ion-content { --offset-bottom: auto !important; --overflow: auto; background: var(--ion-toolbar-background, var(--ion-background-color, #000000)) !important; overflow: auto; &::-webkit-scrollbar { width: 5px; height: 5px; } &::-webkit-scrollbar-track { background: rgb(0, 0, 0); } &::-webkit-scrollbar-track:hover { background: #35d703; } &::-webkit-scrollbar-thumb { background: rgb(75, 75, 75); } &::-webkit-scrollbar-thumb:hover { background: #94173a } .inner-scroll { scrollbar-width: thin; } }
Your scrolling will look like this in ion-modal