react-component / react-component/slider

How to setup a tooltip in latest version

Open
#1,061 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.1k
Forks
768
Avg merge
11d 22h
Merged PRs (30d)
5

Description

This is my code

import React, { useState } from 'react';
import Slider from 'rc-slider';
import 'rc-slider/assets/index.css';
import "./style.css";
import sliderImg from "@/assets/images/png/slider_texture.png";

// TimeSlider.jsx
const TimeSlider = () => {
    const [availableRange, setAvailableRange] = useState([0, 1440]);
    const [awayRange, setAwayRange] = useState([480, 1020]);

    const minutesToTime = (mins) => {
        const hours = Math.floor(mins / 60);
        const minutes = mins % 60;
        const ampm = hours >= 12 ? 'PM' : 'AM';
        const formattedHour = hours % 12 || 12;
        return `${formattedHour}${ampm}`;
    };
    const trackStyle = [{
        backgroundColor: "#d6a94a",
        backgroundImage: `url(${sliderImg})`,
        height: "22px"
    }];

    const sliderChange = (data) => {
        console.log("data", data)
        setAwayRange(data)
    }

    
    return (
        <div>
            <h3>AVAILABLE</h3>
            <Slider range 
                min={availableRange[0]}
                max={availableRange[1]}
                step={60}
                value={awayRange}
                // defaultValue={[3, 10]} 
                onChange={(data) => sliderChange(data)}
                trackStyle={trackStyle}
            />
            <br></br>
            <br></br>
            <p>{minutesToTime(availableRange[0])} - {minutesToTime(availableRange[1])}</p>
        </div>
    );
};

export default TimeSlider;


How to set a tooltip in above code.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the provided TimeSlider.jsx example and inspect the rc-slider Slider API and current project documentation for tooltip support. Confirm which version and usage pattern apply, then document a working tooltip setup for the range slider and verify that the tooltip appears for both handles.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.