Skip to content
Khoa Pham@onmyway133

How to clear background for TextField inside list in macOS

1 min read

When using TextField in SwiftUI List on Mac, it has unwanted background color when focused. We can turn it off using introspection or a custom TextField wrapper

TextField("Search", text: $searchText)
    .introspect(.textField, on: .macOS(.v14, .v15)) {
        $0.drawsBackground = true
        $0.backgroundColor = .clear
    }

Keep reading

Type to search titles and full text.

↑ ↓ move↵ openPagefind