A checkbox is a standard User Interface element in the Apple world. As such, you would expect SwiftUI to have a Checkbox View element. But that is not the case. As of 2020, there is no some thing as a Checkbox View in SwiftUI. But SwiftUI does allow you to create standard iOS and macOS checkboxes. You just have to know what element to use.
There is absolutely no need to create a custom View with a checkbox image or anything like that. Simply use the Toggle SwiftUI element with a styling set to CheckboxToggleStyle().
Here’s an example View with a builtin SwiftUI:
struct ContentView: View {
@State private var checked = true
var body: some View {
Toggle(isOn: $checked) {
Text("Checkbox")
}.toggleStyle(CheckboxToggleStyle())
}
}
That is all you need to create native checkboxes in SwiftUi. It’s super easy, but when I first searched for a checkbox component all the stack overflow answers that I found had people implementing custom Views.