<!--
{
  "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/FocusedValues/subscript(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI13FocusedValuesVy5ValueQzSgxmcAA0cE3KeyRzluip"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

Reads and writes values associated with a given focused value key.

```
subscript<Key>(key: Key.Type) -> Key.Value? where Key : FocusedValueKey { get set }
```

## Overview

Use this subscript to get or set a focused value for a custom
[`FocusedValueKey`](/documentation/SwiftUI/FocusedValueKey). In most cases, you’ll use the `Entry` macro
to create focused value properties, which automatically generates
the appropriate key and uses this subscript internally:

```
extension FocusedValues {
    @Entry var myCustomValue: MyType?
}
```

---

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)