Skip to main content

Slider

The Slider component in our library is a user interface element used to enable users to select a value from a continuous range. It typically appears as a horizontal bar with a draggable thumb that users can slide along the bar to adjust the value. Sliders are commonly used in applications for settings such as volume control, brightness adjustment, or selecting a price range.

Usage

Basic usage

import {Slider} from 'rn-inkpad';

const MyComponent = () => {
return <Slider />;
};

Props

NameTypeDefaultDescription
maxValuenumber100Maximum value the slider can reach.
minValuenumber0Minimum value of the slider.
thumbStylesThumbStylesThumbStyles defaultThumb custom styles.
trackStylesTrackStylesTrackStyles defaultTrack custom styles.
valuenumber0Slider current value.
onChange(value: number) => voidFunction that is executed when moving the slider and returns the current value of the slider.

ThumbStyles props

NameTypeDefaultDescription
backgroundColorstring#FFFFFFThumb background color.
borderRadiusnumber50Thumb border radius.
heightnumber40Thumb height.
iconstringThumb icon.
iconColorstring#4D67FFThumb icon color.
iconSizenumber20Thumb icon size.
shadowbooleantrueShow or hide the shadow on the thumb.
widthnumber40Thumb width.

TrackStyles props

NameTypeDefaultDescription
borderRadiusnumberTrack border radius.
heightnumber5Track height.
trackColorstring#CECECETrack background color.
trackCompletedColorstring#4D67FFCompleted track background color.

Usage props

import React, {useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';

import {Slider} from 'rn-inkpad';

const MyComponent = () => {
const [value, setValue] = useState(false);

return (
<View>
<Slider
thumbStyles={{
icon: 'analytics',
iconColor: '#DB504A',
}}
trackStyles={{
height: 10,
borderRadius: 5,
trackCompletedColor: '#DB504A',
}}
value={value}
onChange={setValue}
/>

<Text style={styles.text}>{value}</Text>
</View>
);
};

const styles = StyleSheet.create({
text: {
fontSize: 18,
fontWeight: '600',
marginTop: 20,
textAlign: 'center',
},
});

Example with props