Animate State change in SwiftUI

Just add the animation modifier to wrap your button

  var body: some View {
    VStack {
      TextField($text, placeholder: Text("Foo")) {
        print("editing ended")
      }
//      if !text.isEmpty {
        Button(action: {}) {
          Text("Done")
        }
        .background(text.isEmpty ? Color.red : Color.yellow )
         //.animation(.basic(duration: 1))
        .animation(Animation.default.speed(1))
      }
    }
  }

TextField("Placeholder", text:$text.animation())

Everything that uses the text will be animated when it is changed.