1.0.10 • Published 4 years ago

rn-toggle v1.0.10

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

RN-Toggle

A customizable toggle switch for React Native that works on Android and iOS without any extra installation steps.

Demo

20200829_025333_edited

Installation:

$ npm install rn-toggle

Basic Usage:

import Toggle from 'rn-toggle';
....
const [isActive, setIsActive] = useState(false);
....
<Toggle isActive={isActive} toggle={() => setIsActive(value => !value)} />

Customized Usage:

import Toggle from 'rn-toggle';
....
const [isActive, setIsActive] = useState(false);
....
<Toggle
	width={70}
	isActive={isActive}
	toggle={() => setIsActive(value => !value)}
	activeColor='#000000'
	text={isActive ? 'on ' : 'off'}
	textStyle={{ color: isActive ? '#FFFFFF' : '#666666' }}
	cursorColor='#FF0000'
	inactiveColor='#FFFFFF'
	borderColor='#FF0000'
/>

Props

NameTypeRequiredDefaultDescription
containerStyleObjectno{}Styling for the outermost component
isActiveBooleannofalseValue that determines whether the toggle is switched on or off
toggleFunctionno() => nullAction to perform when the toggle switch is pressed
widthIntegerno50Sets the width of the toggle switch
durationIntegerno150Time that the animation takes in milliseconds
textStyleObjectno{}Styling for the toggle text
textStringnonullText to display on the toggle
disabledBooleannofalseValue that determines whether the toggle switch is disabled or not
verticalBooleannofalseValue that determines whether the toggle switch is vertical or horizontal
cursorColorHexadecimal Stringno'#FFFFFF'Sets the color of the cursor
borderColorHexadecimal Stringno'#EEEEEE'Sets the border color of the toggle switch
activeColorHexadecimal Stringno'#4CD862'Sets the color of the toggle switch when active
inactiveColorHexadecimal Stringno'#DDDDDD'Sets the color of the toggle switch when inactive

Contributing

Pull requests are always welcome! Feel free to open a new GitHub issue for any changes that can be made.

License

MIT

Authors

1.0.10

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago