
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
react-native-toggle-element
Advanced tools
Switch toggle component for React Native. You can add title, icon, modify component for toggle button.
yarn add react-native-toggle-element
# or with npm
npm install react-native-toggle-element
import React, { useState } from 'react';
import Toggle from 'react-native-toggle-element';
const [toggleValue, setToggleValue] = useState(false);
<Toggle value={toggleValue} onPress={(val) => setToggleValue(val)} />
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="On"
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="Right"
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="Left"
rightTitle="Right"
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftComponent={
<Icon name="credit" width="30" height="30" fill={"#3BD2B5"} />
}
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
rightComponent={
<Icon name="plus" width="30" height="30" fill={'#3BD2B5'} />
}
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
disabled
leftComponent={
<Icon name="credit" width="30" height="30" fill={Colors.tabIconSelected} />
}
rightComponent={
<Icon name="plus" width="30" height="30" fill={Colors.tabIconSelected} />
}
/>
<ToggleButton
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
thumbActiveComponent={
<Icon name="sun" width="40" height="40" fill={'#3BD2B5'} />
}
thumbInActiveComponent={
<Icon name="night" width="40" height="40" fill={'#03452C'} />
}
trackBar={{
activeBackgroundColor: '#9ee3fb',
inActiveBackgroundColor: '#3c4145',
borderActiveColor: '#86c3d7',
borderInActiveColor: '#1c1c1c',
borderWidth: 5,
width: 100,
}}
/>
<Toggle
disabled
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="Left"
rightTitle="Right"
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="Left"
rightTitle="Right"
trackBar={{
width: 200,
height: 50,
radius: 25,
}}
/>
TrackBarStyle will override Border active color & Border inactive color
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
trackBarStyle={{
borderColor: 'green',
}}
trackBar={{
borderWidth: 2,
}}
/>
<Toggle
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="Left"
rightTitle="Right"
thumbButton={{
width: 60,
height: 60,
radius: 30,
}}
/>
<Toggle
disabled
disabledTitleStyle={{ color: 'red' }}
disabledStyle={{ backgroundColor: 'gray', opacity: 0.3 }}
value={toggleValue}
onToggle={(newState) => setToggleValue(newState)}
leftTitle="Left"
rightTitle="Right"
/>
Type | Default |
---|---|
React element or component | none |
containerStyle
style for main container
Type | Default |
---|---|
style | none |
disabled
disable the Toggle Button component (optional)
Type | Default |
---|---|
boolean | false |
disabledStyle
styling for Toggle Button Component for disabled (optional)
Type | Default |
---|---|
View style (object) | none |
disabledTitleStyle
styling for leftTitle & right Title(optional) when Toggle Button set with status is disabled(optional). If you want to set disable style for Active & Inactive you should use custom left component or custom right component
Type | Default |
---|---|
Text style (object)) | none |
leftComponent
define your left component here
Type | Default |
---|---|
React element or component | none |
leftTitle
button left title (optional)
Type | Default |
---|---|
string | none |
rightComponent
define your right component here (optional)
Type | Default |
---|---|
React element or component | none |
rightTitle
button right title (optional)
Type | Default |
---|---|
string | none |
thumbActiveComponent
define your thumb button component when status is active (optional)
Type | Default |
---|---|
React element or component | none |
thumbInActiveComponent
define your thumb button component when status is inactive (optional)
Type | Default |
---|---|
React element or component | none |
thumbStyle
thumb button style (optional). Styling will override the value from thumbButton props
Type | Default |
---|---|
View style (object) | none |
thumbButton
define to change size and radius and color depend on active / inactive status (optional)
Type | Default |
---|---|
borderWidth | 0 |
width | 50 |
height | 50 |
radius | 25 |
activeBackgroundColor | #fde2e2 |
inActiveBackgroundColor | #ffb6b6 |
trackBar
define to change size and radius and color depend on active / inactive status (optional)
Type | Default |
---|---|
borderWidth | 0 |
width | 50 |
height | 50 |
radius | 25 |
activeBackgroundColor | #fde2e2 |
inActiveBackgroundColor | #ffb6b6 |
borderActiveColor | transparent |
borderInActiveColor | transparent |
trackBarStyle
trackbar style (optional). Styling will override the value from trackBar props
Type | Default |
---|---|
View style (object) | none |
FAQs
Switch toggle component for React Native. You can add title, icon, modify component for toggle button.
The npm package react-native-toggle-element receives a total of 6,258 weekly downloads. As such, react-native-toggle-element popularity was classified as popular.
We found that react-native-toggle-element demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.