Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style a Slider Thumb with Styled Components

I am trying to style a slider with styled-components for React, but I do not get how I can style the thumb. I have a CSS that looks like this:

.faderInput::-webkit-slider-thumb {
   -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border:1px solid black;
    ...
}

and my styled component looks like this

const FaderInput = styled.input`
    ...
    ::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 15px;
        height: 15px;
        border:1px solid black;
        ...
  }
`;

Does anybody know how I can port this class selector to styled-components?

like image 615
modmoto Avatar asked Dec 21 '17 09:12

modmoto


2 Answers

I actually got help. You have to add a & and then it looks like this:

 const FaderInput = styled.input`
 ...
 &::-webkit-slider-thumb {
     -webkit-appearance: none;
     width: 15px;
     height: 15px;
     border:1px solid black;
     ...
  }
like image 51
modmoto Avatar answered Nov 11 '22 21:11

modmoto


This is what works well for me in Chrome and Safari. For FF you have to use this FF scrollbar

   const ScrollContainer = styled.div`
    width: 100%;
    height: 500px;
    overflow-y: auto;
    position: relative;
    &::-webkit-scrollbar {
        width: 10px;
        border: 1px solid black;
    }
`;
like image 20
Błażej Grzeliński Avatar answered Nov 11 '22 21:11

Błażej Grzeliński