23

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

1
  • 2
    One cannot write pesudo selectors as inline styles.. Commented Nov 17, 2017 at 8:25

3 Answers 3

16

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
seems that it doesn't work in pure React
this worked in css in react project, for inline styling use Franceso's answer.
15

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

3 Comments

According to the answer of @Elena this is not correct
"Page not found" When visiting this 'link'
I fixed the link.
4

React suggests this

<div style={{ '&::WebkitScrollbar': { width: 0, height: 0 } }}></div>

2 Comments

not sure why I received a negative vote, that is what React suggests on console when I try to add "webkit-scrollbar", and it works
Could you please add a link to a source

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.