import SwiftUI
struct User {
var name: String
}
struct UserView: View {
@Binding var user: User
var body: some View {
VStack {
Text("Hello, \(user.name)")
TextField("Enter your name", text: $user.name)
}
}
}
struct ContentView: View {
@State var user = User(name: "John Doe")
var body: some View {
UserView(user: $user)
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter