This is a pure javascript and react-native-svg based library that provides many variants of Radial Slider
and Speedo Meter
including default
, radial-circle-slider
, speedometer
and speedometer-marker
Radial Slider allows you to select any specific value from a range of values. It comes with two variants, one is default which allows selection on a 180-degree arc and the second one is 360-degree which allows selection of values on a complete circle. It can be used to select/set goals, vision, range, etc.
The Speedo Meter allows you to highlight a specific value from a range of values. It comes with two variants, the default one shows a needle and another one shows marking values with a needle. It can be used to display the speed of the internet, vehicle, fan, etc.
This library is easy to use and provides you complete customization, so you can customize components based on your need.
RadialSlider | SpeedoMeter |
---|---|
Installation | RadialSlider | SpeedoMeter | Properties | Example | License
$ npm install react-native-radial-slider react-native-svg
# --- or ---
$ yarn add react-native-radial-slider react-native-svg
cd ios && pod install
Know more about react-native-svg
- RadialSlider has two different variants, 'default' and 'radial-circle-slider'
- RadialSlider can be used to select / set goal, vision, range etc
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { RadialSlider } from 'react-native-radial-slider';
const RadialVariant = () => {
const [speed, setSpeed] = useState(0);
return (
<View style={styles.container}>
<RadialSlider value={speed} min={0} max={200} onChange={setSpeed} />
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
});
export default RadialVariant;
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { RadialSlider } from 'react-native-radial-slider';
const RadialVariant = () => {
const [speed, setSpeed] = useState(0);
return (
<View style={styles.container}>
<RadialSlider
variant={'radial-circle-slider'}
value={speed}
min={0}
max={200}
onChange={setSpeed}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
});
export default RadialVariant;
The speedometer will not take user inputs, when we need to update dynamic values at that time we can use it
- SpeedoMeter has two different variants, speedometer and speedometer-marker
- SpeedoMeter can be used to display the speed of an internet, vehicle, fan etc
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { RadialSlider } from 'react-native-radial-slider';
const SpeedoMeterVariant = () => {
const [speed, setSpeed] = useState(0);
return (
<View style={styles.container}>
<RadialSlider
variant={'speedometer'}
value={speed}
min={0}
max={200}
onChange={setSpeed}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
});
export default SpeedoMeterVariant;
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { RadialSlider } from 'react-native-radial-slider';
const SpeedoMeterVariant = () => {
const [speed, setSpeed] = useState(0);
return (
<View style={styles.container}>
<RadialSlider
variant={'speedometer-marker'}
value={speed}
min={0}
max={200}
onChange={setSpeed}
/>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
});
export default SpeedoMeterVariant;
Prop | Default | Type | Description | RadialSlider | SpeedoMeter |
---|---|---|---|---|---|
min* | 0 | number | Minimum value | β | β |
max* | 100 | number | Maximum value | β | β |
value* | 0 | number | Show selection upto this value | β | β |
onChange* | - | function | Callback function that invokes on change in track | β | β |
radius | 100 | number | Size of component | β | β |
startAngle | 270 | number [1-360] | The angle at which the circular slider should start from. | β | β |
step | 1 | number | Step value for component | β | β |
markerValue | - | number | Show marker on specific number | β | β |
title | - | string | Title for component | β | β |
subTitle | Goal | string | Subtitle for component | β | β |
unit | RadialSlider: 'kCal', SpeedoMeter: 'MB/S' | string | Unit for component | β | β |
thumbRadius | 18 | number | Radius for thumb | β | β |
thumbColor | #008ABC | string | Color for thumb | β | β |
thumbBorderWidth | 5 | number | Width for thumb | β | β |
thumbBorderColor | #FFFFFF | string | Border Color for thumb | β | β |
markerLineSize | 50 | number | Size of marker line | β | β |
sliderWidth | 18 | number | Width of slider | β | β |
sliderTrackColor | #E5E5E5 | string | Color of unselected slider track | β | β |
lineColor | #E5E5E5 | string | Color of unselected lines | β | β |
lineSpace | 3 | number | Space between each line | β | β |
linearGradient | [ { offset: '0%', color:'#ffaca6' }, { offset: '100%', color: '#EA4800' }] | object | Gradient color of selected track | β | β |
onComplete | - | function | Callback function which defines what to do after completion | β | β |
centerContentStyle | {} | object | Center content style | β | β |
titleStyle | {} | object | Status title container style | β | β |
subTitleStyle | {} | object | Status subtitle text style | β | β |
valueStyle | {} | object | Center value style | β | β |
buttonContainerStyle | {} | object | Button container style | β | β |
leftIconStyle | {} | object | Left Icon style | β | β |
rightIconStyle | {} | object | Right Icon style | β | β |
contentStyle | {} | object | Whole content style | β | β |
unitStyle | {} | object | Unit text style | β | β |
style | {} | object | Inner container style | β | β |
openingRadian | RadialSlider: Math.PI / 3 , SpeedoMeter:0.057 | number | Radian of component | β | β |
disabled | false | boolean | If true, buttons will be in disabled state | β | β |
isHideSlider | false | boolean | If true, slider will be hidden | β | β |
isHideCenterContent | false | boolean | If true, center content will be hidden | β | β |
isHideTitle | false | boolean | If true, title will be hidden | β | β |
isHideSubtitle | false | boolean | If true, subtitle will be hidden | β | β |
isHideValue | false | boolean | If true, value will be hidden | β | β |
isHideTailText | false | boolean | If true, tail text will be hidden | β | β |
isHideButtons | false | boolean | If true, buttons will be hidden | β | β |
isHideLines | false | boolean | If true,slider lines will be hidden | β | β |
isHideMarkerLine | false | boolean | If true, marked lines will be hidden | β | β |
fixedMarker | false | boolean | If true, marked value will be hidden | β | β |
variant | default | string | Different component variants radial-circle-slider , speedometer , speedometer-marker |
β | β |
onPress | {} | function | Based on click value will be increased or decreased | β | β |
stroke | '#008ABC' | string | Color for button icon | β | β |
unitValueContentStyle | {} | object | Unit value content style | β | β |
markerCircleSize | 15 | number | Size for marker circle | β | β |
markerCircleColor | #E5E5E5 | string | Color for marker circle | β | β |
markerPositionY | 20 | number | Marker position for up and down | β | β |
markerPositionX | 20 | number | Marker position for right and left | β | β |
needleBackgroundColor | #A020F0 | string | Background color for needle | β | β |
needleColor | #175BAD | string | Color for needle | β | β |
needleBorderWidth | 1.5 | number | Width of needle border | β | β |
needleHeight | 30 | number | Height of needle | β | β |
markerValueInterval | 10 | number | Show number of value in sequence | β | β |
markerValueColor | #333333 | string | Color for marker value | β | β |
strokeLinecap | butt | string | Line terminations, can be butt, line, or square | β | β |
A full working example project is here Example
yarn
yarn example ios // For ios
yarn example android // For Android
Support it by joining stargazers for this repository.β
We'd love to have you improve this library or fix a problem πͺ Check out our Contributing Guide for ideas on contributing.
For bugs, feature requests, and discussion please use GitHub Issues