slider icon indicating copy to clipboard operation
slider copied to clipboard

I want to display current slider handler position value.

Open srigar opened this issue 6 years ago • 4 comments

Is there anyway to display current slider handler position value? Consider scenario like, When i move slider, the current value need to display under the slider handler

srigar avatar Oct 06 '19 13:10 srigar

You can do this by using a custom handle. Here's how I rendered a date as a tooltip:

handle = props => {
    const { value, dragging, index, ...restProps } = props;
    return (
      <Tooltip
        prefixCls="rc-slider-tooltip"
        overlay={moment.unix(value).format(dateFormat)}
        visible={dragging}
        placement="top"
        key={index}
      >
        <Handle value={value} {...restProps} />
      </Tooltip>
    );
};
  
<Range
    allowCross={true}
    defaultValue={this.props.dateBounds}
    step={500}
    handle={this.handle}
    min={this.props.dateBounds[0]}
    max={this.props.dateBounds[1]}
    value={this.props.dateRange}
    onChange={value => {
      this.updateSelectedRange(value);
    }}
/>

tooltip

sweetgiorni avatar Nov 15 '19 02:11 sweetgiorni

@sweetgiorni - ToolTip component you used - is it custom or you using a library?

mdere-unbound avatar Mar 24 '20 21:03 mdere-unbound

@mdere-unbound

It's the rc-tooltip library. See this example: https://github.com/react-component/slider/blob/master/examples/handle.jsx

sweetgiorni avatar Mar 25 '20 01:03 sweetgiorni

Also possible to get the tooltip done without rc-tooltip, only using CSS:

.rc-slider-handle:before {
     content: attr(aria-valuenow) ' %';  // to display current value of slider
    /* style your tooltip */
}

naazim avatar Sep 16 '20 16:09 naazim