CustomToggle – SwiftUI


Swift Package Manager

Open Xcode, go to File -> Swift Packages -> Add Package Dependency and enter as Branch main

You need to add import CustomToggle


Untitled (1)

  • See avaliable styles and their usages

Style 1

BounceToggle(status: $isOpen, colorClose: .gray, colorOpen: .brown, thumbColor: .white)
    //.scaleEffect(1.8).padding() // use scaleEffect to resize toggle

Style 2

BounceToggle(status: $isOpen, colorClose: .cyan, colorOpen: .teal, thumbColor: .white,enableLine: true)

Style 3

IconToggle(status: $isOpen) // see other parameters to customize fully
IconToggle(status: $isOpen, iconClose: "lock.fill", iconClsClr: .white, backClose: .red, iconOpen: "", iconOpnClr: .white, backOpen: .green, thumbColor: .white)

Style 4

IconToggle(status: $isOpen, backClose: .gray.opacity(0.4), backOpen: .indigo.opacity(0.8), thumbColor: .cyan,disableIcon: true)

Style 5

ThumbToggle(status: $isOpen, backClose: .orange, backOpen: .black, thumbColor: .white)


Parameters Meanings
status shows status of toggle
iconClose shows systemName of icon while toggle closed
iconClsClr shows color of icon while toggle closed
iconOpen shows systemName of icon while toggle opened
iconOpnClr shows color of icon while toggle opened
backOpen shows background color of toggle while opened
thumbColor shows thumb color of toggle
enableLine shows line on center of toggle (see style 2)


View Github