
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@react-native-assets/slider
Advanced tools
Lightweight slider for React-Native and React-Native-Web. A Range slider is included
This lightweight version of a slider is fully compatible with React-Native and React-Native-Web. It also provides support for Range slider (with 2 thumbs) and custom thumb rendering.
@react-native-community/slider
. Now named @callstack/slider
, it is actually not maintained by the community. Thus, you should not worry about switching library for a better implementation if it meets your needs.Try it here!
Have a look at the troubleshooting section if you encounter any issue, or open an issue.
npm i -S @react-native-assets/slider
You can see below the available props with their respective default values.
import { Slider } from '@react-native-assets/slider'
<Slider
value={0} // set the current slider's value
minimumValue={0} // Minimum value (defaults as 0)
maximumValue={0} // Maximum value (defaults as minimumValue + step)
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
minTrackStyle={undefined} // Override the tracks' style for the minimum range
maxTrackStyle={undefined} // Override the tracks' style for the maximum range
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
thumbImage={undefined} // An image that would represent the thumb
slideOnTap={true} // If true, touching the slider will update it's value. No need to slide the thumb.
onValueChange={undefined} // Called each time the value changed. Return false to prevent the value from being updated. The type is (value: number) => boolean | 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
CustomThumb={undefined} // Provide your own component to render the thumb. The type is a component: ({ value: number }) => JSX.Element
StepMarker={undefined} // We now use the component from @callstack/slider to preserve the same API. See the documentation [here](https://github.com/callstack/react-native-slider?tab=readme-ov-file#stepmarker). We add "markValue" that holds the value of the current mark instead of the index only.
CustomTrack={undefined} // Provide your own component to render the track. The type is a component: ({ length: number; thickness: number; vertical: boolean; track: 'min' | 'max' ; style: RN.StyleProp<RN.ViewStyle>; color: RN.ColorValue }) => JSX.Element ; The props describe how the default system would expect the track to be rendered, but you can ignore them if you want to provide your own implementation
{...props} // Add any View Props that will be applied to the container (style, ref, etc)
/>
You can see below the available props with their respective default values
import { RangeSlider } from '@react-native-assets/slider'
<RangeSlider
range={[0, 0]} // set the current slider's value
step={0} // The step for the slider (0 means that the slider will handle any decimal value within the range [min, max])
minimumRange={0} // Minimum range between the two thumbs (defaults as "step")
minimumValue={0} // Minimum value (defaults as 0)
maximumValue={0} // Maximum value (defaults as minimumValue + minimumRange)
crossingAllowed={false} // If true, the user can make one thumb cross over the second thumb
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
minTrackStyle={undefined} // Override the tracks' style for the minimum range
midTrackStyle={undefined} // Override the tracks' style for the middle range
maxTrackStyle={undefined} // Override the tracks' style for the maximum range
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
thumbImage={undefined} // An image that would represent the thumb
slideOnTap={true} // If true, touching the slider will update it's value. No need to slide the thumb.
onValueChange={undefined} // Called each time the value changed. Return false to prevent the value from being updated. The type is (range: [number, number]) => boolean | 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
CustomThumb={undefined} // Provide your own component to render the thumb. The type is a component: ({ value: number, thumb: 'min' | 'max' }) => JSX.Element
StepMarker={undefined} // We now use the component from @callstack/slider to preserve the same API. See the documentation [here](https://github.com/callstack/react-native-slider?tab=readme-ov-file#stepmarker). We add "markValue" that holds the value of the current mark instead of the index only.
CustomTrack={undefined} // Provide your own component to render the track. The type is a component: ({ length: number; thickness: number; vertical: boolean; track: 'min' | 'max' ; style: RN.StyleProp<RN.ViewStyle>; color: RN.ColorValue }) => JSX.Element ; The props describe how the default system would expect the track to be rendered, but you can ignore them if you want to provide your own implementation
{...props} // Add any View Props that will be applied to the container (style, ref, etc)
/>
The component is probably too narrow. Increase the height of the component to ensure a correct touch area
CustomMark
prop with StepMarker
prop so we follow the same API as @callstack/slider in order to ease migrationCustomMark
optional component. It had a wrong size and wrong positionCustomTrack
component to render the trackonValueChange
callbackRangeSlider
componentCustomMark
prop to provide your own component to render the places where the thumb can stopRangeSlider
tooSlider
value not updating when provided through propsrange
prop in RangeSlider
thumbImage
prop (please report if you encounter an issue with it)onLayout
callbackminTrackStyle
prop on Slider and RangeSlidermaxTrackStyle
prop on Slider and RangeSlidermidTrackStyle
prop on RangeSlidercrossingAllowed
prop on RangeSliderminimumRange
prop on RangeSliderAnimatedSlider
and AnimatedRangeSlider
slideOnTap
propIf you have any issue, please fill an issue on our repo
FAQs
Lightweight slider for React-Native and React-Native-Web. A Range slider is included
The npm package @react-native-assets/slider receives a total of 10,986 weekly downloads. As such, @react-native-assets/slider popularity was classified as popular.
We found that @react-native-assets/slider demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.