DEV Community

Saurabh Chavan
Saurabh Chavan

Posted on • Updated on

How Button & function work in swiftUI

When we click on the button then value will update on the screen

import SwiftUI

struct ContentView: View {
    @State private var name = ""

    var body: some View {
            Button("click me",role: .destructive, action: Clicked).buttonStyle(.borderedProminent).tint(.green).foregroundColor(.black)
            Text("Hello \(name)")

      func Clicked(){
               name = "Saurabh"


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
Enter fullscreen mode Exit fullscreen mode


Image description

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git