Skip to main content

Purpose

MNSwitchButton is a React Native toggle switch component that lets users switch between two states: on and off. It features:

  • A label displayed next to the switch.
  • Customizable colors for switch background and toggle circle in both states.
  • Optional icons or images inside the toggle circle for on/off states.
  • Disabled mode to prevent interaction.
  • Controlled internal state with callback on change.

Import

import MNSwitchButtons from '@/components/ui/forms/switchBtns/MNSwitchButtons';

Props

PropTypeRequiredDefaultDescription
labelstringYes-Text label displayed beside the switch
onChange(value: boolean) => voidYes-Callback called when switch state changes
valuebooleanNofalseInitial or controlled value of the switch
checkedImageImageSourcePropTypeNo-Image or icon shown inside toggle when switch is ON
unCheckImageImageSourcePropTypeNo-Image or icon shown inside toggle when switch is OFF
disabledbooleanNofalseWhether the switch is disabled (non-interactive)
bgOnColorstringNoLIGHTBLUE_COLORBackground color of switch when ON
bgOffColorstringNoLIGHTBLUE_COLORBackground color of switch when OFF
circleOnstringNo'transparent'Color of toggle circle when ON
circleOffstringNo'transparent'Color of toggle circle when OFF
onIconstringNo-Ionicons icon name shown when ON
offIconstringNo-Ionicons icon name shown when OFF

Usage Example

<MNSwitchButton
label="Enable notifications"
value={switchOn}
onChange={setSwitchOn}
bgOnColor="#4CAF50"
bgOffColor="#CCC"
circleOn="#FFF"
circleOff="#FFF"
onIcon="notifications"
offIcon="notifications-off"
/>

NOTE: All example can be founded in radio_buttons.tsx