<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/PreferenceKey",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13PreferenceKeyP"
  },
  "title" : "PreferenceKey"
}
-->

# PreferenceKey

A named value produced by a view.

```
protocol PreferenceKey
```

## Overview

A view with multiple children automatically combines its values for a given
preference into a single value visible to its ancestors.

## Topics

### Getting the default value

[`defaultValue`](/documentation/SwiftUI/PreferenceKey/defaultValue)

The default value of the preference.

[`Value`](/documentation/SwiftUI/PreferenceKey/Value)

The type of value produced by this preference.

### Combining preferences

[`reduce(value:nextValue:)`](/documentation/SwiftUI/PreferenceKey/reduce(value:nextValue:))

Combines a sequence of values by modifying the previously-accumulated
value with the result of a closure that provides the next value.

## Relationships

### Conforming Types

[`LayoutKey`](/documentation/SwiftUI/Text/LayoutKey)

[`PreferredColorSchemeKey`](/documentation/SwiftUI/PreferredColorSchemeKey)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)