List Background Prominence
The prominence of the background underneath views associated with this environment.
Platform Compatibility
iOS 17.0+ iPadOS 17.0+ macOS 14.0+ watchOS 10.0+ tvOS 17.0+ visionOS 1.0+
Tags
SwiftUI Code
@State var selectedEntry: String? = "Foo"
let entries = ["Foo", "Bar"]
private struct EntryItem: View {
let text: String
var body: some View {
VStack(alignment: .leading) {
HStack {
EntryItemChild(text: text)
}
}
}
}
private struct EntryItemChild: View {
let text: String
@Environment(\.backgroundProminence) private var backgroundProminence
var body: some View {
if backgroundProminence == .increased {
Text(text)
.bold()
.italic()
} else {
Text(text)
.foregroundStyle(Color.accentColor)
}
}
}
var body: some View {
VStack {
List(entries, id: \.self, selection: $selectedEntry) { entry in
EntryItem(text: entry)
}
}
Found an issue or have a suggestion?
Created: August 10, 2025Updated: August 10, 2025