
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
react-simple-range
Advanced tools
A simple React component to input a number between a min and a max value using a slider
A simple React slider component for inputting a number value within a range.
npm install react-simple-range --save
Import React and this component using your chosen module bundler:
import React from 'react';
import ReactDOM from 'react-dom';
import ReactSimpleRange from 'react-simple-range';
const rootElement = document.getElementById('app');
ReactDOM.render(<ReactSimpleRange />, rootElement);
Name | Type | Default | Description |
---|---|---|---|
min | number | 0 | Minimum slider value |
max | number | 100 | Maximum slider value |
step | number | 1 | Number inc/decremented when slider value is changed. The range of the slider (max - min) should be evenly divisible by this |
id | string | null | Identifier that is passed to the onChange handler (see below) |
onChange | function | NOOP | Function to be called when the slider value changes - your slider will have no effect without this! See below for more information |
onChangeComplete | function | NOOP | Function to be called when user interaction finishes, sends the same values as the onChange handler, the only difference is they get sent when the interaction has ended |
defaultValue | number | 0 | Set initial value of slider |
vertical | boolean | false | Set slider to vertical when true |
verticalSliderHeight | string | 100px | Default slider height if vertical. If your slider already has a fixed height wrapper, just set this to 100% and the slider will fill the space |
eventWrapperPadding | number | 8 | Px value to add padding to the wrapper to make small sliders easier to interact with |
label | boolean | false | If true, adds a label displaying the slider's value when interacted with |
disableThumb | boolean | false | Disables the thumb when true |
disableTrack | boolean | false | Disables the track when true |
sliderSize | number | 4 | Px height of slider if horizontal, width if vertical |
thumbSize | number | sliderSize * 2 | Height and width of thumb in px |
sliderColor | string | #9E9E9E | Color of slider |
trackColor | string | #03A9F4 | Color of track and label |
thumbColor | string | #fff | Color of thumb |
customThumb | element | undefined | Pass in a single React element to use as your thumb, replacing the default |
The onChange handler receives the following arguments:
value
and ratio
(percentage of bar filled)id
prop of the sliderAn alternative change handler which only sends the argument at the end of the mouse drag
PRs are welcome. Submit issues for any bugs or feature requests.
Name | Effect |
---|---|
npm start | Runs react-styleguidist, serving examples at http://localhost:6060/ |
npm run test | Runs tests with jest |
npm run test:watch | Runs tests in watch mode |
FAQs
A simple React component to input a number between a min and a max value using a slider
The npm package react-simple-range receives a total of 90 weekly downloads. As such, react-simple-range popularity was classified as not popular.
We found that react-simple-range demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.