---
title: Preferences
framework: swiftui
role: collectionGroup
role_heading: API Collection
path: swiftui/preferences
---

# Preferences

Indicate configuration preferences from views to their container views.

## Overview

Overview Whereas you use the environment to configure the subviews of a view, you use preferences to send configuration information from subviews toward their container. However, unlike configuration information that flows down a view hierarchy from one container to many subviews, a single container needs to reconcile potentially conflicting preferences flowing up from its many subviews.

When you use the PreferenceKey protocol to define a custom preference, you indicate how to merge preferences from multiple subviews. You can then set a value for the preference on a view using the preference(key:value:) view modifier. Many built-in modifiers, like navigationTitle(_:), rely on preferences to send configuration information to their container.

## Topics

### Setting preferences

- [preference(key:value:)](swiftui/view/preference(key:value:).md)
- [transformPreference(_:_:)](swiftui/view/transformpreference(_:_:).md)

### Creating custom preferences

- [PreferenceKey](swiftui/preferencekey.md)

### Setting preferences based on geometry

- [anchorPreference(key:value:transform:)](swiftui/view/anchorpreference(key:value:transform:).md)
- [transformAnchorPreference(key:value:transform:)](swiftui/view/transformanchorpreference(key:value:transform:).md)

### Responding to changes in preferences

- [onPreferenceChange(_:perform:)](swiftui/view/onpreferencechange(_:perform:).md)

### Generating backgrounds and overlays from preferences

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

## See Also

### Data and storage

- [Model data](swiftui/model-data.md)
- [Environment values](swiftui/environment-values.md)
- [Persistent storage](swiftui/persistent-storage.md)
