
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-native-sticky-range-slider
Advanced tools
[React Native | TypeScript] A pure TypeScript component offering a customizable range slider optimized for performance. It supports dragging functionalities for selecting a range of values, with values that smoothly follow the thumb. This component is ful
A pure TS component offering a customizable range slider optimized for performance.
It supports dragging functionalities for selecting a range of values, with values that smoothly follow the thumb.
This component is fully compatible with both Android and iOS platforms.
Primarily forked from rn-range-slider.
npm install react-native-sticky-range-slider
yarn add react-native-sticky-range-slider
import React, { useCallback, useState } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import RangeSlider from "react-native-sticky-range-slider";
const MIN_AGE = 18;
const MAX_AGE = 60;
const Thumb = (type: "high" | "low") => (
<View
style={[styles.thumb, { backgroundColor: type === "high" ? "lime" : "purple" }]}
/>
);
const Rail = () => <View style={styles.rail} />;
const RailSelected = () => <View style={styles.railSelected} />;
const App = () => {
const [min, setMin] = useState(MIN_AGE);
const [max, setMax] = useState(MAX_AGE);
const [disableRange, setDisableRange] = useState(false);
const handleValueChange = useCallback((newLow: number, newHigh: number) => {
setMin(newLow);
setMax(newHigh);
}, []);
const handleToggle = () => {
setDisableRange((prev) => !prev);
};
return (
<View style={styles.container}>
<Text style={styles.title}>{disableRange ? "Set your age" : "Set Age Range"}</Text>
<RangeSlider
style={styles.slider}
min={MIN_AGE}
max={MAX_AGE}
step={1}
minRange={5}
low={min}
high={max}
onValueChanged={handleValueChange}
renderLowValue={(value) => <Text style={styles.valueText}>{value}</Text>}
renderHighValue={(value) => (
<Text style={styles.valueText}>{value === MAX_AGE ? `+${value}` : value}</Text>
)}
renderThumb={Thumb}
renderRail={Rail}
renderRailSelected={RailSelected}
disableRange={disableRange}
/>
<Button
onPress={handleToggle}
title={disableRange ? "Switch to double control" : "Switch to single control"}
/>
</View>
);
};
const THUMB_RADIUS = 10;
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
padding: 20,
},
title: {
fontSize: 24,
textAlign: "center",
marginBottom: 20,
},
slider: {
marginVertical: 20,
},
valueText: {
color: "black",
},
thumb: {
width: THUMB_RADIUS * 2,
height: THUMB_RADIUS * 2,
borderRadius: THUMB_RADIUS,
borderWidth: 3,
borderColor: "black",
backgroundColor: "red",
},
rail: {
flex: 1,
height: 3,
borderRadius: 3,
backgroundColor: "grey",
},
railSelected: {
height: 3,
backgroundColor: "red",
},
});
export default App;
Name | Description | Type | Default Value |
---|---|---|---|
min | Minimum value for the slider. | number | required |
max | Maximum value for the slider. | number | required |
minRange | Minimum range between the low and high values. It is set to 0 if disableRange is true . | number | 0 |
step | Step value for the slider. | number | required |
low | Low value for the slider. | number | required |
high | High value for the slider. | number | required |
onValueChanged | Callback function that gets called when the slider values change. Receives the new low and high values as arguments. | (low: number, high: number) => void | required |
renderThumb | Function to render the thumb component. Accepts a type parameter which can be either high or low. | (type: 'high' or 'low') => React.ReactNode | Default Thumb |
renderRail | Function to render the rail component. | () => React.ReactNode | Default Rail |
renderRailSelected | Function to render the selected rail component. | () => React.ReactNode | Default RailSelected |
renderLowValue | Function to render the component displaying the low value. Receives the low value as an argument. | (low: number) => React.ReactNode | Default LowValueText |
renderHighValue | Function to render the component displaying the high value. Receives the high value as an argument. | (high: number) => React.ReactNode | Default HighValueText |
pannableAreaStyle | Style for the pannable area. | StyleProp<ViewStyle> | Default Pannable Area Style |
disableRange | When set to true , the slider functions as a standard slider with a single control. | boolean | false |
disabled | User interactions will be ignored when set to true . | boolean | false |
Contributions are welcome! If you have any suggestions, feature requests, or bug reports, feel free to open an issue or submit a pull request. Let's make this component even better together! 😃
MIT
Made with create-react-native-library
FAQs
[React Native | TypeScript] A pure TypeScript component offering a customizable range slider optimized for performance. It supports dragging functionalities for selecting a range of values, with values that smoothly follow the thumb. This component is ful
The npm package react-native-sticky-range-slider receives a total of 97 weekly downloads. As such, react-native-sticky-range-slider popularity was classified as not popular.
We found that react-native-sticky-range-slider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.