Skip to content

A custom SwiftUI ToggleStyle for switching between light and dark mode

License

Notifications You must be signed in to change notification settings

puthnith/SunMoonToggleStyle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SunMoonToggleStyle

A custom SwiftUI ToggleStyle for switching between light and dark mode.

SunMoonToggleStyle

How-to

  1. First, FileSwift PackagesAdd Package Dependancy...
  2. Then, paste the repo link https://github.com/puthnith/SunMoonToggleStyle, then click Next and Finish
  3. Now add import SunMoonToggleStyle
  4. And use it as Toggle(...).toggleStyle(SunMoonToggleStyle())

Example

struct ContentView: View {
  @State private var isOn: Bool = false

  var body: some View {
    VStack {
      Toggle(isOn: $isOn, label: label)
        .toggleStyle(SunMoonToggleStyle())
    }
    .padding()
  }

  func label() -> Text {
    isOn ? Text("Moon") : Text("Sun")
  }
}

Dribbble

Inspired by Dribbble - Light / Dark mode toggle switcher

About

A custom SwiftUI ToggleStyle for switching between light and dark mode

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages