🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-native-option-switch

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-option-switch

Options switch component for React Native. It can be used as radio button or boolean switch.

1.2.2
latest
Source
npm
Version published
Weekly downloads
16
220%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-option-switch

The React Native component to provide UI with option selection like radio button or yes/no choice.

Demo:

Demo

Install

npm i --save react-native-option-switch

Params

ParamDescription
options (required)An array of options, each option is an object with particular fields: key(don't use with isBool={true}), title, value, isDefault (optional).
onChangeA handler of the value change event. A function that accepts a new value as the first param.
stylesObject with custom styles for the component. You can use these fields to customize whole component (container field), items (item and selectedItem) and item labels (label).
isNullableDefault is false. Set true in case of nothing to select.

Usage

<View style={{ flex: 1, justifyContent: 'center' }}>
	<Text style={{
		fontWeight: '600',
		fontSize: 18,
		margin: 16,
		marginBottom: 8,
		textAlign: 'center'
	}}>One option selection, with nullable option</Text>
	<OptionSwitch
		isNullable={true}
		styles={{
			item: {
				width: 100,
				height: 24,
				borderRadius: 12,
				marginHorizontal: 8,
				alignItems: 'center',
			},
			selectedItem: {
				width: 100,
				height: 24,
				borderRadius: 12,
				marginHorizontal: 8,
				backgroundColor: '#FDE08C',
				alignItems: 'center',
			},
		}}
		options={[
			{
				label: 'First',
				value: 'first'
			}, {
				label: 'Second',
				value: 'second',
				isDefault: true,
			}, {
				label: 'Third',
				value: 'third',
			}
		]}
	/>
	<Text style={{
		fontWeight: '600',
		fontSize: 18,
		margin: 24,
		marginBottom: 8,
		textAlign: 'center'
	}}>Boolean choice</Text>
	<OptionSwitch
		onChange={(value) => {

		}}
		options={[
			{
				label: 'Yes',
				value: false
			}, {
				label: 'No',
				value: true,
				isDefault: true,
			}
		]}
	/>
  </View>

Keywords

react-native

FAQs

Package last updated on 09 Jun 2020

Did you know?

Socket

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.

Install

Related posts