<!--
{
  "availability" : [
    "macOS: 10.15.0 - 12.0.0",
    "tvOS: 13.0.0 - 15.0.0",
    "watchOS: 6.0.0 - 8.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/focusable(_:onFocusChange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE9focusable_13onFocusChangeQrSb_ySbctF"
  },
  "title" : "focusable(_:onFocusChange:)"
}
-->

# focusable(_:onFocusChange:)

Specifies if the view is focusable and, if so, adds an action to perform
when the view comes into focus.

```
nonisolated func focusable(_ isFocusable: Bool = true, onFocusChange: @escaping (Bool) -> Void = { _ in }) -> some View
```

## Parameters

`isFocusable`

A Boolean value that indicates whether this view is
focusable.

`onFocusChange`

A closure that’s called whenever this view either gains
or loses focus. The Boolean parameter to `onFocusChange` is `true` when
the view is in focus; otherwise, it’s `false`.

## Return Value

A view that sets whether a view is focusable, and triggers
`onFocusChange` when the view gains or loses focus.

---

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)