Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-range

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-range

Range input. Slides in all directions.

  • 1.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
149K
decreased by-10.31%
Maintainers
1
Weekly downloads
 
Created

What is react-range?

The react-range package is a flexible, customizable range slider component for React applications. It allows developers to create sliders with multiple handles, custom styling, and various configurations to suit different use cases.

What are react-range's main functionalities?

Basic Range Slider

This code sample demonstrates a basic range slider with a single handle. The slider ranges from 0 to 100, and the handle can be moved in steps of 1.

import { Range } from 'react-range';

const BasicRangeSlider = () => {
  const [values, setValues] = React.useState([50]);
  return (
    <Range
      step={1}
      min={0}
      max={100}
      values={values}
      onChange={(values) => setValues(values)}
      renderTrack={({ props, children }) => (
        <div {...props} style={{ ...props.style, height: '6px', background: '#ccc' }}>
          {children}
        </div>
      )}
      renderThumb={({ props }) => (
        <div {...props} style={{ ...props.style, height: '20px', width: '20px', background: '#999' }} />
      )}
    />
  );
};

Multi-Handle Range Slider

This code sample demonstrates a range slider with two handles. The slider ranges from 0 to 100, and each handle can be moved in steps of 1.

import { Range } from 'react-range';

const MultiHandleRangeSlider = () => {
  const [values, setValues] = React.useState([20, 80]);
  return (
    <Range
      step={1}
      min={0}
      max={100}
      values={values}
      onChange={(values) => setValues(values)}
      renderTrack={({ props, children }) => (
        <div {...props} style={{ ...props.style, height: '6px', background: '#ccc' }}>
          {children}
        </div>
      )}
      renderThumb={({ props }) => (
        <div {...props} style={{ ...props.style, height: '20px', width: '20px', background: '#999' }} />
      )}
    />
  );
};

Custom Styled Range Slider

This code sample demonstrates a range slider with custom styling. The track has a gradient background, and the thumb is styled as a red circle.

import { Range } from 'react-range';

const CustomStyledRangeSlider = () => {
  const [values, setValues] = React.useState([30]);
  return (
    <Range
      step={1}
      min={0}
      max={100}
      values={values}
      onChange={(values) => setValues(values)}
      renderTrack={({ props, children }) => (
        <div {...props} style={{ ...props.style, height: '8px', background: 'linear-gradient(to right, #0f0, #00f)' }}>
          {children}
        </div>
      )}
      renderThumb={({ props }) => (
        <div {...props} style={{ ...props.style, height: '24px', width: '24px', background: '#f00', borderRadius: '50%' }} />
      )}
    />
  );
};

Other packages similar to react-range

Keywords

FAQs

Package last updated on 07 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc