22

How can I apply the ::-webkit-scrollbar pseudo elements to a component using inline styling in React?

galah92
  • 3,621
  • 2
  • 29
  • 55

3 Answers3

14

You can't write pseudo selector inline, you need to add it in css. Refer this link

Martin54
  • 1,349
  • 2
  • 13
  • 34
satyajit rout
  • 1,623
  • 10
  • 20
14

This worked in my project '&::-webkit-scrollbar': { width: 0, }

Elena
  • 141
  • 1
  • 3
  • 3
    Welcome to SO. Please take time to explain your answers rather than just post code. When answering an older question with other, accepted answers, also explain how your answer is different or an improvement/update on the others. – rmlockerd Aug 06 '21 at 22:13
  • seems that it doesn't work in pure React – Pavel Shepelenko Feb 10 '23 at 14:41
1

React suggests this

<div style={{ '&::WebkitScrollbar': { width: 0, height: 0 } }}></div>
Francesco Orsi
  • 1,739
  • 4
  • 16
  • 32