<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/FocusedValueKey",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15FocusedValueKeyP"
  },
  "title" : "FocusedValueKey"
}
-->

# FocusedValueKey

A protocol for identifier types used when publishing and observing focused
values.

```
protocol FocusedValueKey
```

## Overview

Unlike [`EnvironmentKey`](/documentation/SwiftUI/EnvironmentKey), `FocusedValueKey` has no default value
requirement, because the default value for a key is always `nil`.

Use the `Entry` macro to create custom focused values by extending
`FocusedValues` with new properties:

```
extension FocusedValues {
    @Entry var selectedItem: Item?
}
```

Alternatively it is possible to create a focused value key by manually
creating a type that conforms to this protocol:

```
struct SelectedItemKey: FocusedValueKey {
    typealias Value = Item
}
```

Then extend [`FocusedValues`](/documentation/SwiftUI/FocusedValues) to add a computed property for your key:

```
extension FocusedValues {
    var selectedItem: Item? {
        get { self[SelectedItemKey.self] }
        set { self[SelectedItemKey.self] = newValue }
    }
}
```

## Topics

### Specifying the value type

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



---

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)