|
Download react-use/docs/useSlider.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 599 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useSlider.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useSlider.md
-
curl -L -o useSlider.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useSlider.md
599 Bytes
| # `useSlider` | |
| React UI hook that provides slide behavior over any HTML element. Supports both mouse and touch events. | |
| ## Usage | |
| ```jsx | |
| import {useSlider} from 'react-use'; | |
| const Demo = () => { | |
| const ref = React.useRef(null); | |
| const {isSliding, value, pos, length} = useSlider(ref); | |
| return ( | |
| <div> | |
| <div ref={ref} style={{ position: 'relative' }}> | |
| <p style={{ textAlign: 'center', color: isSliding ? 'red' : 'green' }}> | |
| {Math.round(value * 100)}% | |
| </p> | |
| <div style={{ position: 'absolute', left: pos }}>🎚</div> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| ``` | |