slider icon indicating copy to clipboard operation
slider copied to clipboard

dotStyle seems to not be working

Open otherjohn opened this issue 5 years ago • 6 comments

I would like to customize the dot in the slider by changing the background color and border. Here is my code:

<Slider
          min={0}
          max={2000000}
          value={Number(home)}
          onChange={getChangeHandler}
          step={10000}
          defaultValue="250000"
          trackStyle={{ backgroundColor: '#43d89f', height: 8 }}
          dotStyle={{backgroundColor: '#f04823', borderColor: '#f04823'}}
          activeDotStyle={{ backgroundColor: '#f04823', borderColor: '#f04823' }}
        />

The track style changed but not the dotStyle, it still has the same default color. I have tried it with activeDotStyle also and got the same results.

otherjohn avatar Jun 26 '20 14:06 otherjohn

Agreed, same issue here

KeRusty avatar Nov 09 '20 12:11 KeRusty

I'm facing the issue too

KelvinMitaki avatar Dec 22 '20 21:12 KelvinMitaki

I will try fix this.

kerm1it avatar Dec 23 '20 03:12 kerm1it

@KeRusty @KelvinMitaki You need to set dots to true

<Slider
  min={0}
  max={20000}
  defaultValue={3}
  dots
  step={10000}
  trackStyle={{ backgroundColor: '#43d89f', height: 8 }}
  dotStyle={{backgroundColor: '#f04823', borderColor: '#f04823'}}
  activeDotStyle={{ backgroundColor: '#f04823', borderColor: '#f04823' }}
/>

This is screenshots:

image

kerm1it avatar Dec 23 '20 04:12 kerm1it

Setting dots to true does not solve the issue for me. Instead of effecting the active dot, it adds tons of span tags and the styles get applied to the track instead.

Screen Shot 2021-05-05 at 4 34 50 PM
<Slider
    activeDotStyle={{
      transform: 'scale(1.3)',
      backgroundColor: 'red',
    }}
    dots
    handleStyle={{
      borderColor: 'var(--sw-blue)',
    }}
    max={maxValue}
    min={minValue}
    onAfterChange={() => setDragging(false)}
    onBeforeChange={() => setDragging(true)}
    onChange={(val) => updateValue(val)}
    step={0.1}
    trackStyle={{ backgroundColor: 'var(--sw-blue)' }}
    value={controlledValue}
  />

jmargolisvt avatar May 05 '21 20:05 jmargolisvt

Override all slider styles possible only with:

import styles from './Styles.module.scss'

<Slider
    ...
    className={styles.slider}
/>

CSS module:

.slider {
  & :global(.rc-slider-track) {
    background-color: #aeaeae;
  }
}

With :global you can override all internal class name. P.S: SCSS for convenience, this is all implementable in pure CSS

fresonn avatar Dec 17 '23 13:12 fresonn