# InteractionSource

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/interaction/InteractionSource.kt+class:androidx.compose.foundation.interaction.InteractionSource) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0) Common/All
- Cmn

  ```
  interface InteractionSource
  ```
Known direct subclasses [MutableInteractionSource](https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` | MutableInteractionSource represents a stream of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s corresponding to events emitted by a component. |

*** ** * ** ***

InteractionSource represents a stream of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s corresponding to events emitted by a component. These `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s can be used to change how components appear in different states, such as when a component is pressed or dragged.

A common use case is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/indication.modifier#(androidx.compose.ui.Modifier).indication(androidx.compose.foundation.interaction.InteractionSource,androidx.compose.foundation.Indication)`, where `https://developer.android.com/reference/kotlin/androidx/compose/foundation/Indication` implementations can subscribe to an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource` to draw indication for different `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s, such as a ripple effect for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Press` and a state overlay for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction.Start`.

For simple cases where you are interested in the binary state of an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`, such as whether a component is pressed or not, you can use `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/collectIsPressedAsState.composable#(androidx.compose.foundation.interaction.InteractionSource).collectIsPressedAsState()` and other extension functions that subscribe and return a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether the component is in this state or not.

```kotlin
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.indication
import androidx.compose.foundation.interaction.Interaction
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsDraggedAsState
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

// Hoist the MutableInteractionSource that we will provide to interactions
val interactionSource = remember { MutableInteractionSource() }

// Provide the MutableInteractionSource instances to the interactions we want to observe state
// changes for
val draggable =
    Modifier.draggable(
        interactionSource = interactionSource,
        orientation = Orientation.Horizontal,
        state = rememberDraggableState { /* update some business state here */ },
    )

val clickable =
    Modifier.clickable(
        interactionSource = interactionSource,
        indication = LocalIndication.current,
    ) { /* update some business state here */
    }

// Observe changes to the binary state for these interactions
val isDragged by interactionSource.collectIsDraggedAsState()
val isPressed by interactionSource.collectIsPressedAsState()

// Use the state to change our UI
val (text, color) =
    when {
        isDragged && isPressed -> "Dragged and pressed" to Color.Red
        isDragged -> "Dragged" to Color.Green
        isPressed -> "Pressed" to Color.Blue
        // Default / baseline state
        else -> "Drag me horizontally, or press me!" to Color.Black
    }

Box(Modifier.fillMaxSize().wrapContentSize().size(width = 240.dp, height = 80.dp)) {
    Box(
        Modifier.fillMaxSize()
            .then(clickable)
            .then(draggable)
            .border(BorderStroke(3.dp, color))
            .padding(3.dp)
    ) {
        Text(
            text,
            style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
            modifier = Modifier.fillMaxSize().wrapContentSize(),
        )
    }
}
```

For more complex cases, such as when building an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/Indication`, the order of the events can change how a component / indication should be drawn. For example, if a component is being dragged and then becomes focused, the most recent `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` is `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/FocusInteraction.Focus`, so the component should appear in a focused state to signal this event to the user.

InteractionSource exposes `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()` to support these use cases - a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` representing the stream of all emitted `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s. This also provides more information, such as the press position of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Press`, so you can show an effect at the specific point the component was pressed, and whether the press was `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Release` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Cancel`, for cases when a component should behave differently if the press was released normally or interrupted by another gesture.

You can collect from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()` as you would with any other `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`:

```kotlin
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.indication
import androidx.compose.foundation.interaction.DragInteraction
import androidx.compose.foundation.interaction.Interaction
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

// Hoist the MutableInteractionSource that we will provide to interactions
val interactionSource = remember { MutableInteractionSource() }

// Provide the MutableInteractionSource instances to the interactions we want to observe state
// changes for
val draggable =
    Modifier.draggable(
        interactionSource = interactionSource,
        orientation = Orientation.Horizontal,
        state = rememberDraggableState { /* update some business state here */ },
    )

val clickable =
    Modifier.clickable(
        interactionSource = interactionSource,
        // This component is a compound component where part of it is clickable and part of it
        // is
        // draggable. As a result we want to show indication for the _whole_ component, and not
        // just for clickable area. We set `null` indication here and provide an explicit
        // Modifier.indication instance later that will draw indication for the whole component.
        indication = null,
    ) { /* update some business state here */
    }

// SnapshotStateList we will use to track incoming Interactions in the order they are emitted
val interactions = remember { mutableStateListOf<Interaction>() }

// Collect Interactions - if they are new, add them to `interactions`. If they represent stop /
// cancel events for existing Interactions, remove them from `interactions` so it will only
// contain currently active `interactions`.
LaunchedEffect(interactionSource) {
    interactionSource.interactions.collect { interaction ->
        when (interaction) {
            is PressInteraction.Press -> interactions.add(interaction)
            is PressInteraction.Release -> interactions.remove(interaction.press)
            is PressInteraction.Cancel -> interactions.remove(interaction.press)
            is DragInteraction.Start -> interactions.add(interaction)
            is DragInteraction.Stop -> interactions.remove(interaction.start)
            is DragInteraction.Cancel -> interactions.remove(interaction.start)
        }
    }
}

// Display some text based on the most recent Interaction stored in `interactions`
val text =
    when (interactions.lastOrNull()) {
        is DragInteraction.Start -> "Dragged"
        is PressInteraction.Press -> "Pressed"
        else -> "No state"
    }

Column(Modifier.fillMaxSize().wrapContentSize()) {
    Row(
        // Draw indication for the whole component, based on the Interactions dispatched by
        // our hoisted MutableInteractionSource
        Modifier.indication(
            interactionSource = interactionSource,
            indication = LocalIndication.current,
        )
    ) {
        Box(
            Modifier.size(width = 240.dp, height = 80.dp)
                .then(clickable)
                .border(BorderStroke(3.dp, Color.Blue))
                .padding(3.dp)
        ) {
            val pressed = interactions.any { it is PressInteraction.Press }
            Text(
                text = if (pressed) "Pressed" else "Not pressed",
                style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
                modifier = Modifier.fillMaxSize().wrapContentSize(),
            )
        }
        Box(
            Modifier.size(width = 240.dp, height = 80.dp)
                .then(draggable)
                .border(BorderStroke(3.dp, Color.Red))
                .padding(3.dp)
        ) {
            val dragged = interactions.any { it is DragInteraction.Start }
            Text(
                text = if (dragged) "Dragged" else "Not dragged",
                style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
                modifier = Modifier.fillMaxSize().wrapContentSize(),
            )
        }
    }
    Text(
        text = text,
        style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
        modifier = Modifier.fillMaxSize().wrapContentSize(),
    )
}
```

To emit `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s so that consumers can react to them, see `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` |   |

## Summary

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction>` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#interactions()` `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` representing the stream of all `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s emitted through this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource`. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource.https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#(androidx.compose.foundation.interaction.InteractionSource).collectIsDraggedAsState()()` Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is dragged or not. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource.https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#(androidx.compose.foundation.interaction.InteractionSource).collectIsFocusedAsState()()` Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is focused or not. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource.https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#(androidx.compose.foundation.interaction.InteractionSource).collectIsHoveredAsState()()` Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is hovered or not. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource.https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource#(androidx.compose.foundation.interaction.InteractionSource).collectIsPressedAsState()()` Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is pressed or not. | Cmn |

## Public properties

### interactions

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
val interactions: Flow<Interaction>
```

`https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` representing the stream of all `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s emitted through this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource`. This can be used to see `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s emitted in order, and with additional metadata, such as the press position for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Press`.

```kotlin
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.draggable
import androidx.compose.foundation.gestures.rememberDraggableState
import androidx.compose.foundation.indication
import androidx.compose.foundation.interaction.DragInteraction
import androidx.compose.foundation.interaction.Interaction
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp

// Hoist the MutableInteractionSource that we will provide to interactions
val interactionSource = remember { MutableInteractionSource() }

// Provide the MutableInteractionSource instances to the interactions we want to observe state
// changes for
val draggable =
    Modifier.draggable(
        interactionSource = interactionSource,
        orientation = Orientation.Horizontal,
        state = rememberDraggableState { /* update some business state here */ },
    )

val clickable =
    Modifier.clickable(
        interactionSource = interactionSource,
        // This component is a compound component where part of it is clickable and part of it
        // is
        // draggable. As a result we want to show indication for the _whole_ component, and not
        // just for clickable area. We set `null` indication here and provide an explicit
        // Modifier.indication instance later that will draw indication for the whole component.
        indication = null,
    ) { /* update some business state here */
    }

// SnapshotStateList we will use to track incoming Interactions in the order they are emitted
val interactions = remember { mutableStateListOf<Interaction>() }

// Collect Interactions - if they are new, add them to `interactions`. If they represent stop /
// cancel events for existing Interactions, remove them from `interactions` so it will only
// contain currently active `interactions`.
LaunchedEffect(interactionSource) {
    interactionSource.interactions.collect { interaction ->
        when (interaction) {
            is PressInteraction.Press -> interactions.add(interaction)
            is PressInteraction.Release -> interactions.remove(interaction.press)
            is PressInteraction.Cancel -> interactions.remove(interaction.press)
            is DragInteraction.Start -> interactions.add(interaction)
            is DragInteraction.Stop -> interactions.remove(interaction.start)
            is DragInteraction.Cancel -> interactions.remove(interaction.start)
        }
    }
}

// Display some text based on the most recent Interaction stored in `interactions`
val text =
    when (interactions.lastOrNull()) {
        is DragInteraction.Start -> "Dragged"
        is PressInteraction.Press -> "Pressed"
        else -> "No state"
    }

Column(Modifier.fillMaxSize().wrapContentSize()) {
    Row(
        // Draw indication for the whole component, based on the Interactions dispatched by
        // our hoisted MutableInteractionSource
        Modifier.indication(
            interactionSource = interactionSource,
            indication = LocalIndication.current,
        )
    ) {
        Box(
            Modifier.size(width = 240.dp, height = 80.dp)
                .then(clickable)
                .border(BorderStroke(3.dp, Color.Blue))
                .padding(3.dp)
        ) {
            val pressed = interactions.any { it is PressInteraction.Press }
            Text(
                text = if (pressed) "Pressed" else "Not pressed",
                style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
                modifier = Modifier.fillMaxSize().wrapContentSize(),
            )
        }
        Box(
            Modifier.size(width = 240.dp, height = 80.dp)
                .then(draggable)
                .border(BorderStroke(3.dp, Color.Red))
                .padding(3.dp)
        ) {
            val dragged = interactions.any { it is DragInteraction.Start }
            Text(
                text = if (dragged) "Dragged" else "Not dragged",
                style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
                modifier = Modifier.fillMaxSize().wrapContentSize(),
            )
        }
    }
    Text(
        text = text,
        style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
        modifier = Modifier.fillMaxSize().wrapContentSize(),
    )
}
```

## Extension functions

### InteractionSource.collectIsDraggedAsState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/interaction/DragInteraction.kt+function:collectIsDraggedAsState)

```
@Composable
fun InteractionSource.collectIsDraggedAsState(): State<Boolean>
```

Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is dragged or not.

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction` is typically set by interactions such as `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/draggable.modifier#(androidx.compose.ui.Modifier).draggable(androidx.compose.foundation.gestures.DraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean,kotlin.coroutines.SuspendFunction2,kotlin.coroutines.SuspendFunction2,kotlin.Boolean)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/scrollable.modifier#(androidx.compose.ui.Modifier).scrollable(androidx.compose.foundation.gestures.ScrollableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.gestures.FlingBehavior,androidx.compose.foundation.interaction.MutableInteractionSource)`, and higher level components such as `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/LazyRow.composable#LazyRow(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.ui.Alignment.Vertical,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,kotlin.Function1)`, available through `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/LazyListState#interactionSource()`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is being dragged or not |

### InteractionSource.collectIsFocusedAsState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/interaction/FocusInteraction.kt+function:collectIsFocusedAsState)

```
@Composable
fun InteractionSource.collectIsFocusedAsState(): State<Boolean>
```

Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is focused or not.

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/FocusInteraction` is typically set by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/focusable.modifier#(androidx.compose.ui.Modifier).focusable(kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource)` and focusable components, such as `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/BasicTextField.composable#BasicTextField(androidx.compose.foundation.text.input.TextFieldState,androidx.compose.ui.Modifier,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.text.input.InputTransformation,androidx.compose.ui.text.TextStyle,androidx.compose.foundation.text.KeyboardOptions,androidx.compose.foundation.text.input.KeyboardActionHandler,androidx.compose.foundation.text.input.TextFieldLineLimits,kotlin.Function2,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Brush,androidx.compose.foundation.text.input.OutputTransformation,androidx.compose.foundation.text.input.TextFieldDecorator,androidx.compose.foundation.ScrollState)`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is being focused or not |

### InteractionSource.collectIsHoveredAsState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/interaction/HoverInteraction.kt+function:collectIsHoveredAsState)

```
@Composable
fun InteractionSource.collectIsHoveredAsState(): State<Boolean>
```

Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is hovered or not.

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/HoverInteraction` is typically set by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/hoverable.modifier#(androidx.compose.ui.Modifier).hoverable(androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean)` and hoverable components.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is being hovered or not |

### InteractionSource.collectIsPressedAsState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/interaction/PressInteraction.kt+function:collectIsPressedAsState)

```
@Composable
fun InteractionSource.collectIsPressedAsState(): State<Boolean>
```

Subscribes to this `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` and returns a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is pressed or not.

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction` is typically set by `https://developer.android.com/reference/kotlin/androidx/compose/foundation/clickable.modifier#(androidx.compose.ui.Modifier).clickable(kotlin.Boolean,kotlin.String,androidx.compose.ui.semantics.Role,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function0)` and clickable higher level components, such as buttons.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State` representing whether this component is being pressed or not |