zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
892 stars 231 forks source link

renderThumb: not working using styled component #154

Closed vdhyani-binary closed 4 years ago

vdhyani-binary commented 4 years ago

const thumb = (props, state) => <StyledThumb {...props}>{state.valueNow}; renderTumb ={Thumb}

s1

above code is showing overlap all the thumb with single showing track, when i used below code instead of above now i can see all track with all the thumb but now i am not getting Thumb rapup. not working so i used

s2

renderThumb={(props, state) => <div style={{border:'1px solid black',margin:'20px'}} {...props}>{state.valueNow}

}

stonebk commented 4 years ago

Have you looked at the very last example in the documentation? It is using styled-components and renderThumb: https://zillow.github.io/react-slider/

vdhyani-binary commented 4 years ago

yes! i have used in same way

stonebk commented 4 years ago

Are you referring to the fact that your border and margin is not showing up?

The render function passes style as one of the props that you are spreading onto the div, and since it comes after your own style attribute, it is overriding it.

You need to merge the style objects if you want to use inline styles like that.

renderThumb={(props, state) => <div style={{border:'1px solid black',margin:'20px', ...props.style}} {...props}>{state.valueNow}}