Toggle

Custom toggle component

See it on Snack

import { Toggle, Icon } from "react-native-magnus";

const [on, toggle] = useState(false);

<Toggle
  on={on}
  onPress={() => toggle(!on)}
  bg="gray200"
  circleBg="blue500"
  activeBg="blue700"
  h={30}
  w={60}
/>;

Props

PropertyDescriptionTypeDefault
mmargin`stringnumber`
mtmargin top`stringnumber`
mrmargin right`stringnumber`
mbmargin bottom`stringnumber`
mlmargin margin left`stringnumber`
mxmargin horizonal`stringnumber`
mymargin vertical`stringnumber`
ppadding`stringnumber`
ptpadding top`stringnumber`
prpadding right`stringnumber`
pbpadding bottom`stringnumber`
plpadding margin left`stringnumber`
pxpadding horizonal`stringnumber`
pypadding vertical`stringnumber`
hheightnumber-
wwidthnumber-
bgbackground colorstring-
circleBgbackground color of circlestring-
activeCircleBgbackground color of circle when toggle is onstring-
disableddisables onPress handler when trueboolean-
onPressonPress event handler() => void-
onmakes the toggle active when truebooleanfalse
roundedborder radius`stringnumber`
roundedTopborder radius top`stringnumber`
roundedBottomborder radius bottom`stringnumber`
roundedLeftborder radius left`stringnumber`
roundedRightborder radius right`stringnumber`
borderColorcolor for borderstring-
borderTopColorcolor for border topstring-
borderRightColorcolor for border rightstring-
borderLeftColorcolor for border leftstring-
borderBottomColorcolor for border bottomstring-
borderWidthwidth for bordernumber-
borderTopWidthwidth for border topnumber-
borderRightWidthwidth for border rightnumber-
borderLeftWidthwidth for border leftnumber-
borderBottomWidthwidth for border bottomnumber-