---
title: "FocusState"
description: "The focus state of a [FocusTargetNode]. Use [onFocusChanged] or [onFocusEvent] modifiers to
access [FocusState]."
type: "interface"
---

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


<a id='references'></a>

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



```kotlin
interface FocusState
```


The focus state of a `FocusTargetNode`. Use `onFocusChanged` or `onFocusEvent` modifiers to
access `FocusState`.


## Properties

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


```kotlin
val isFocused: Boolean
```


Whether the component is focused or not.

#### Returns

| | |
| --- | --- |
|  | true if the component is focused, false otherwise. |




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


```kotlin
val hasFocus: Boolean
```


Whether the focus modifier associated with this `FocusState` has a child that is focused.

#### Returns

| | |
| --- | --- |
|  | true if a child is focused, false otherwise. |




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


```kotlin
val isCaptured: Boolean
```


Whether focus is captured or not. A focusable component is in a captured state when it wants
to hold onto focus. (Eg. when a text field has an invalid phone number). When we are in a
captured state, clicking on other focusable items does not clear focus from the currently
focused item.

You can capture focus by calling `focusRequester.captureFocus()` and free focus
by calling `focusRequester.freeFocus()`.

#### Returns

| | |
| --- | --- |
|  | true if focus is captured, false otherwise. |





## Code Examples

### FocusableSample
```kotlin
@Composable
fun FocusableSample() {
    var color by remember { mutableStateOf(Black) }
    Box(
        Modifier.border(2.dp, color)
            // The onFocusChanged should be added BEFORE the focusable that is being observed.
            .onFocusChanged { color = if (it.isFocused) Green else Black }
            .focusable()
    )
}
```

