Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
/ slider Public archive
forked from Sharcoux/slider

React-Native and React-Native-Web compatible slider

Notifications You must be signed in to change notification settings

sandvikcode/slider

 
 

Repository files navigation

React Native Slider

This Implementation of a slider is fully compatible with React-Native and React-Native-Web. It also provides support for Range slider (with 2 thumbs)

Install

npm i -S @sharcoux/slider

Usage

Slider

You can see below the available props with their respective default values

import { Slider } from '@sharcoux/slider'

<Slider
  value={0}                         // set the current slider's value
  minimumValue={0}                  // Minimum value
  maximumValue={1}                  // Maximum value
  step={0}                          // The step for the slider (0 means that the slider will handle any decimal value within the range [min, max])
  minimumTrackTintColor='grey'      // The track color before the current value
  maximumTrackTintColor='grey'      // The track color after the current value
  thumbTintColor='darkcyan'         // The color of the slider's thumb
  thumbStyle={undefined}            // Override the thumb's style
  trackStyle={undefined}            // Override the tracks' style
  vertical={false}                  // If true, the slider will be drawn vertically
  inverted={false}                  // If true, min value will be on the right, and max on the left
  enabled={true}                    // If false, the slider won't respond to touches anymore
  trackHeight={4}                   // The track's height in pixel
  thumbSize={15}                    // The thumb's size in pixel
  onValueChange={undefined}         // Called each time the value changed. The type is (value: number) => void
  onSlidingStart={undefined}        // Called when the slider is pressed. The type is (value: number) => void
  onSlidingComplete={undefined}     // Called when the press is released. The type is (value: number) => void
  {...props}                        // Add any View Props that will be applied to the container (style, ref, etc)
/>

Range Slider

You can see below the available props with their respective default values

import { Range } from '@sharcoux/slider'

<Range
  range={[0, 1]}                    // set the current slider's value
  minimumValue={0}                  // Minimum value
  maximumValue={1}                  // Maximum value
  step={0}                          // The step for the slider (0 means that the slider will handle any decimal value within the range [min, max])
  outboundColor='grey'              // The track color outside the current range value
  inboundColor='grey'               // The track color inside the current range value
  thumbTintColor='darkcyan'         // The color of the slider's thumb
  thumbStyle={undefined}            // Override the thumb's style
  trackStyle={undefined}            // Override the tracks' style
  vertical={false}                  // If true, the slider will be drawn vertically
  inverted={false}                  // If true, min value will be on the right, and max on the left
  enabled={true}                    // If false, the slider won't respond to touches anymore
  trackHeight={4}                   // The track's height in pixel
  thumbSize={15}                    // The thumb's size in pixel
  onValueChange={undefined}         // Called each time the value changed. The type is (range: [number, number]) => void
  onSlidingStart={undefined}        // Called when the slider is pressed. The type is (range: [number, number]) => void
  onSlidingComplete={undefined}     // Called when the press is released. The type is (range: [number, number]) => void
  {...props}                        // Add any View Props that will be applied to the container (style, ref, etc)
/>

Better performance with Animated API

If you have issues with performances, you can try to use these implementations instead:

Slider

import { AnimatedSlider } from '@sharcoux/slider'

<AnimatedSlider
  {...props}
/>

Range Slider

import { AnimatedRange } from '@sharcoux/slider'

<AnimatedRange
  {...props}
/>

If you have any issue, please fill an issue on our repo

About

React-Native and React-Native-Web compatible slider

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • TypeScript 62.8%
  • Java 12.1%
  • Ruby 10.3%
  • Objective-C 8.6%
  • JavaScript 5.0%
  • Starlark 1.2%