---
title: "setTextAndSelectAll"
description: "Sets the text in this [TextFieldState] to [text], replacing any text that was previously there,
and selects all the text.

To perform more complicated edits on the text, call [TextFieldState.edit]. This function is
equivalent to calling:
```
edit { replace(0, length, text) selectAll()
}
```"
type: "function"
---

<div class='type'>Function</div>


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


```kotlin
fun TextFieldState.setTextAndSelectAll(text: String)
```


Sets the text in this `TextFieldState` to `text`, replacing any text that was previously there,
and selects all the text.

To perform more complicated edits on the text, call `TextFieldState.edit`. This function is
equivalent to calling:
```
edit { replace(0, length, text) selectAll()
}
```



