You can resize the switch by using transform property from styling,
<Switch value={true}
style={{ transform: [{ scaleX: .8 }, { scaleY: .8 }] }}
onValueChange={(value) => {}} />
also for best result determine scaling values based on screen dimension.
Answer from Eltaf Hussain on Stack OverflowReact Native
reactnative.dev › docs › switch
Switch · React Native
1 month ago - On iOS, custom color for the background. This background color can be seen either when the switch value is false or when the switch is disabled (and the switch is translucent).
npm
npmjs.com › package › react-native-switch
react-native-switch - npm
February 21, 2022 - import { Switch } from 'react-native-switch'; export const App = () => ( <Switch value={true} onValueChange={(val) => console.log(val)} disabled={false} activeText={'On'} inActiveText={'Off'} circleSize={30} barHeight={1} circleBorderWidth={3} backgroundActive={'green'} backgroundInactive={'gray'} circleActiveColor={'#30a566'} circleInActiveColor={'#000000'} renderInsideCircle={() => <CustomComponent />} // custom component to render inside the Switch circle (Text, Image, etc.) changeValueImmediately={true} // if rendering inside circle, change state immediately or wait for animation to comple
» npm install react-native-switch
Published Feb 21, 2022
Version 1.5.1
Videos
React Native Switch Component Tutorial: How to Implement ...
React Native Tutorial - 61 - Switch
09:05
React Native Tutorial 26 - React Native Custom Switch Component ...
09:35
React Native Tutorial 25 - React Native Switch Example - YouTube
09:22
React Native Tutorial 24 - React Native Switch - YouTube
Medium
medium.com › @songyishu.yang › react-native-switch-recolor-resize-6dc6a2ce183a
React Native Switch: recolor & resize | by Songyishu Yang | Medium
April 11, 2019 - Missing in React Native Switch Documentation… · To change the color of the switch when turned ON: Add props onTintColor = color · To resize the size of the switch to smaller or larger: Add props style = transformation: [{scaleX: resizeRatio},{scaleY:rezieRatio} ] Code example: <Switch onTintColor={Colors.tintColor} onValueChange={value=>this.setState({switchAll:value}} value={this.state.switchAll} style={{ transform:[{ scaleX: .7 }, { scaleY: .7 }] }} /> React Native ·
Top answer 1 of 4
226
You can resize the switch by using transform property from styling,
<Switch value={true}
style={{ transform: [{ scaleX: .8 }, { scaleY: .8 }] }}
onValueChange={(value) => {}} />
also for best result determine scaling values based on screen dimension.
2 of 4
11
To expand on what was already said, this is how you can handle screen sizes:
import { moderateScale } from 'react-native-size-matters';
...
<Switch
style={{ transform: [{ scaleX: moderateScale(1, 0.2) }, { scaleY:
moderateScale(1, 0.2) }] }} />
TutorialsPoint
tutorialspoint.com › react_native › react_native_switch.htm
React Native - Switch
import React, { Component } from ... ({ container: { flex: 1, alignItems: 'center', marginTop: 100 } }) If we press the switch, the state will be updated....
GitHub
github.com › nithinpp69 › react-native-switch-toggles
GitHub - nithinpp69/react-native-switch-toggles: react Native customizable switch component library
import Switch from 'react-native-switch-toggles'; const [isEnabled, setIsEnabled] = React.useState(false); .... <> <Text style={styles.label}>Simple Switch</Text> <Switch value={isEnabled} onChange={(value) => setIsEnabled(value)} /> </> <> <Text style={styles.label}>Switch with on/off indicator</Text> <Switch value={isEnabled} onChange={(value) => setIsEnabled(value)} activeTrackColor={'#45D058'} renderOffIndicator={() => ( <Text style={{ fontSize: 8, color: 'white' }}>OFF</Text> )} renderOnIndicator={() => ( <Text style={{ fontSize: 8, color: 'white' }}>ON</Text> )} /> </> <> <Text style={st
Starred by 19 users
Forked by 3 users
Languages TypeScript 97.3% | JavaScript 2.2% | Shell 0.5% | TypeScript 97.3% | JavaScript 2.2% | Shell 0.5%
GitHub
github.com › shahen94 › react-native-switch
GitHub - shahen94/react-native-switch: Customisable switch component for RN · GitHub
import { Switch } from 'react-native-switch'; export const App = () => ( <Switch value={true} onValueChange={(val) => console.log(val)} disabled={false} activeText={'On'} inActiveText={'Off'} circleSize={30} barHeight={1} circleBorderWidth={3} backgroundActive={'green'} backgroundInactive={'gray'} circleActiveColor={'#30a566'} circleInActiveColor={'#000000'} renderInsideCircle={() => <CustomComponent />} // custom component to render inside the Switch circle (Text, Image, etc.) changeValueImmediately={true} // if rendering inside circle, change state immediately or wait for animation to comple
Starred by 293 users
Forked by 169 users
Languages JavaScript
React Native
doc.ebichu.cc › react-native › releases › 0.43 › docs › switch.html
Switch
'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { Platform, Switch, Text, View } = ReactNative; class BasicSwitchExample extends React.Component { state = { trueSwitchIsOn: true, falseSwitchIsOn: false, }; render() { return ( <View> <Switch onValueChange={(value) => this.setState({falseSwitchIsOn: value})} style={{marginBottom: 10}} value={this.state.falseSwitchIsOn} /> <Switch onValueChange={(value) => this.setState({trueSwitchIsOn: value})} value={this.state.trueSwitchIsOn} /> </View> ); } } class DisabledSwitchExample extends React.Component { rend
GitHub
github.com › baderahmed › react-native-customisable-switch
GitHub - baderahmed/react-native-customisable-switch: A React Native module that allows you to customize switch (style, form and animation), availble for android and IOS. · GitHub
import React, { Component } from 'react'; import { Text, View } from 'react-native'; import Switch from 'react-native-customisable-switch'; export default class Test extends Component { constructor(props) { super(props); this.state = { switchOneValue: false, switchTwoValue: false, switchThreeValue: true, }; } render() { const { switchOneValue, switchTwoValue, switchOneValue, } = this.state; return( <View style={styles.container}> <View style={styles.container}> <Switch value={switchOneValue} onChangeValue={() => this.setState({ switchOneValue: !switchOneValue })} /> </View> <View style={styles
Starred by 38 users
Forked by 28 users
Languages JavaScript
EDUCBA
educba.com › home › software development › software development tutorials › react native tutorial › react-native switch
React-Native Switch | How Switch Component works in React-Native?
April 3, 2023 - import React, { Component } from 'react' import {StyleSheet, Switch, View, Text} from 'react-native' export default class SwitchExample extends Component { state = { switchValue: false }; render() { return ( <View style={styles.container}> <Text style={styles.textStyle}>This is an Example of Switch</Text> <Text style={styles.textStyle}>{this.state.switchValue ?
Call +917738666252
Address Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Callstack
oss.callstack.com › switch
Switch | React Native Paper
import * as React from 'react'; import { Switch } from 'react-native-paper'; const MyComponent = () => { const [isSwitchOn, setIsSwitchOn] = React.useState(false); const onToggleSwitch = () => setIsSwitchOn(!isSwitchOn); return <Switch value={isSwitchOn} onValueChange={onToggleSwitch} />; }; export default MyComponent;
Callstack
oss.callstack.com › react-native-paper › 4.0 › switch.html
Switch · React Native Paper
Custom color for switch. onValueChange · Type: Function · Callback called with the new value when it changes. style · Type: StyleProp<ViewStyle> theme · Type: ReactNativePaper.Theme ·
Javatpoint
javatpoint.com › react-native-switch
React Native Switch - javatpoint
React Native Switch with tutorial, introduction, environment setup, first app hello world, state, props, flexbox, height and width, listview, scrollview, images, buttons, router, etc.