Changing TextEditor background color in SwiftUI for macOS

I would like to change the background color of a SwiftUI text editor on macOS. Is there a variant for the code below (used for iOS) to work for NSTextField instead of UITextView?

Thanks.

Code Block
struct ContentView: View {
@State var text = ""
init() {
UITextView.appearance().backgroundColor = .clear
}
var body: some View {
TextEditor(text: text)
.background(Color.red)
}
}

Try this (as found here: https://stackoverflow.com/questions/65865182/transparent-background-for-texteditor-in-swiftui)

Code Block
extension NSTextView {
  open override var frame: CGRect {
    didSet {
      backgroundColor = .clear
      drawsBackground = true
    }
  }
}
struct ContentView: View {
@State var text = ""
var body: some View {
TextEditor(text: $text)
.background(Color.red)
}
}


If anyone else comes here: The solution proposed by stakes worked for me on macOS BigSur.

This hack is not necessary, this is the SwiftUI way:

 .scrollContentBackground(.hidden)
Changing TextEditor background color in SwiftUI for macOS
 
 
Q