---
title: "focusRestorer"
description: "This modifier can be used to save and restore focus to a focus group. When focus leaves the focus
group, it stores a reference to the item that was previously focused. Then when focus re-enters
this focus group, it restores focus to the previously focused item."
type: "modifier"
---

<div class='type'>Compose Modifier</div>

<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun Modifier.focusRestorer(fallback: FocusRequester = Default): Modifier
```


This modifier can be used to save and restore focus to a focus group. When focus leaves the focus
group, it stores a reference to the item that was previously focused. Then when focus re-enters
this focus group, it restores focus to the previously focused item.

#### Parameters

| | |
| --- | --- |
| fallback | A `FocusRequester` that is used when focus restoration fails to restore the initially focused item. For example, this might happen if the item is not available to be focused. The default value of `FocusRequester.Default` chooses the default focusable item. |




<div class='sourceset sourceset-common'>Common</div>


> **Deprecated** Use focusRestorer(FocusRequester) instead

```kotlin
@ExperimentalComposeUiApi
fun Modifier.focusRestorer(onRestoreFailed: (() -> FocusRequester)?): Modifier
```


Deprecated focusRestorer API. Use the version accepting `FocusRequester` instead of the lambda.
This method will be removed soon after submitting.



## Code Examples
### FocusRestorerCustomFallbackSample
```kotlin
@Composable
fun FocusRestorerCustomFallbackSample() {
    val focusRequester = remember { FocusRequester() }
    LazyRow(
        // If restoration fails, focus would fallback to the item associated with focusRequester.
        Modifier.focusRestorer(focusRequester)
    ) {
        item {
            Button(modifier = Modifier.focusRequester(focusRequester), onClick = {}) { Text("1") }
        }
        item { Button(onClick = {}) { Text("2") } }
        item { Button(onClick = {}) { Text("3") } }
        item { Button(onClick = {}) { Text("4") } }
    }
}
```
### FocusRestorerSample
```kotlin
@Composable
fun FocusRestorerSample() {
    LazyRow(Modifier.focusRestorer()) {
        item { Button(onClick = {}) { Text("1") } }
        item { Button(onClick = {}) { Text("2") } }
        item { Button(onClick = {}) { Text("3") } }
        item { Button(onClick = {}) { Text("4") } }
    }
}
```

