@strv/react-sliders
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@strv/react-sliders

Continuous Integration Dependabot Mergify Status npm latest bundlephobia code style: prettier semantic-release

Features

Install

# npm
npm install @strv/react-sliders --save

# yarn
yarn add @strv/react-sliders

Usage

Basic Examples

useSlider

import React from 'react'
import { useSlider } from '@strv/react-sliders'

const SliderExample = () => {
  const [value, setValue] = React.useState(0)
  const { getRailProps, getTrackProps, getHandleProps } = useSlider({
    value,
    min: 0,
    max: 100,
    onChange: setValue,
  })

  return (
    <div className="slider-container">
      <span className="slider-rail" {...getRailProps()} />
      <span className="slider-track" {...getTrackProps()} />

      <span className="slider-handle" {...getHandleProps()} />
    </div>
  )
}

useRangeSlider

import React from 'react'
import { useRangeSlider, TRangeTuple } from '@strv/react-sliders'

const RangeSliderExample = () => {
  const [value, setValue] = React.useState<TRangeTuple>([0, 100])
  const { getRailProps, getTrackProps, getMinHandleProps, getMaxHandleProps } = useRangeSlider({
    value,
    min: 0,
    max: 100,
    onChange: setValue,
  })

  return (
    <div className="range-slider-container">
      <span className="range-slider-rail" {...getRailProps()} />
      <span className="range-slider-track" {...getTrackProps()} />

      <span className="range-slider-handle" {...getMinHandleProps()} />
      <span className="range-slider-handle" {...getMaxHandleProps()} />
    </div>
  )
}

If you want so see more, head to the list of existing CodeSandbox examples.

Hooks API


Related

This project was bootstrapped with TSDX.

Contribution

See Contributing guide

Authors

License

MIT License

Package Sidebar

Install

npm i @strv/react-sliders

Weekly Downloads

11

Version

1.0.2

License

MIT

Unpacked Size

192 kB

Total Files

26

Last publish

Collaborators

  • lucasconstantino
  • strvuser
  • robertrossmann
  • xhudec