---
title: "focusable(_:onFocusChange:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/focusable(_:onfocuschange:)"
---

# focusable(_:onFocusChange:)

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

## Declaration

```swift
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

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

## See Also

### Input and events modifiers

- [dropDestination(for:action:isTargeted:)](swiftui/view/dropdestination(for:action:istargeted:).md)
- [onChange(of:perform:)](swiftui/view/onchange(of:perform:).md)
- [onTapGesture(count:coordinateSpace:perform:)](swiftui/view/ontapgesture(count:coordinatespace:perform:)-36x9h.md)
- [onLongPressGesture(minimumDuration:maximumDistance:pressing:perform:)](swiftui/view/onlongpressgesture(minimumduration:maximumdistance:pressing:perform:).md)
- [onLongPressGesture(minimumDuration:pressing:perform:)](swiftui/view/onlongpressgesture(minimumduration:pressing:perform:).md)
- [onPasteCommand(of:perform:)](swiftui/view/onpastecommand(of:perform:)-4f78f.md)
- [onPasteCommand(of:validator:perform:)](swiftui/view/onpastecommand(of:validator:perform:)-964k1.md)
- [onDrop(of:delegate:)](swiftui/view/ondrop(of:delegate:)-2vr9o.md)
- [onDrop(of:isTargeted:perform:)](swiftui/view/ondrop(of:istargeted:perform:).md)
- [onContinuousHover(coordinateSpace:perform:)](swiftui/view/oncontinuoushover(coordinatespace:perform:)-8gyrl.md)
