<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/focusedValue(_:_:)-odf9",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12focusedValueyQrs15WritableKeyPathCyAA13FocusedValuesVqd__SgG_AItlF"
  },
  "title" : "focusedValue(_:_:)"
}
-->

# focusedValue(_:_:)

Creates a new view that exposes the provided value to other views whose
state depends on the focused view hierarchy.

```
nonisolated func focusedValue<Value>(_ keyPath: WritableKeyPath<FocusedValues, Value?>, _ value: Value?) -> some View
```

## Parameters

`keyPath`

The key path to associate `value` with when adding
it to the existing table of exported focus values.

`value`

The focus value to export, or `nil` if no value is
currently available.

## Return Value

A modified representation of this view.

## Discussion

Use this method instead of `View/focusedSceneValue(_:_:)` when your
scene includes multiple focusable views with their own associated
values, and you need an app- or scene-scoped element like a command or
toolbar item that operates on the value associated with whichever view
currently has focus. Each focusable view can supply its own 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)