---
title: "backgroundPreferenceValue(_:alignment:_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/backgroundpreferencevalue(_:alignment:_:)"
---

# backgroundPreferenceValue(_:alignment:_:)

Reads the specified preference value from the view, using it to produce a second view that is applied as the background of the original view.

## Declaration

```swift
nonisolated func backgroundPreferenceValue<K, V>(_ key: K.Type, alignment: Alignment = .center, @ContentBuilder _ transform: @escaping (K.Value) -> V) -> some View where K : PreferenceKey, V : View

```

## Parameters

- `key`: The preference key type whose value is to be read.
- `alignment`: An optional alignment to use when positioning the background view relative to the original view.
- `transform`: A function that produces the background view from the preference value read from the original view.

## Return Value

Return Value A view that layers a second view behind the view.

## Discussion

Discussion The values of the preference key from both views are combined and made visible to the parent view.

## See Also

### Generating backgrounds and overlays from preferences

- [backgroundPreferenceValue(_:_:)](swiftui/view/backgroundpreferencevalue(_:_:).md)
- [overlayPreferenceValue(_:_:)](swiftui/view/overlaypreferencevalue(_:_:).md)
- [overlayPreferenceValue(_:alignment:_:)](swiftui/view/overlaypreferencevalue(_:alignment:_:).md)
