# androidx.compose.foundation.interaction

Common/All

## Interfaces

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction` | An interaction related to drag events. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/FocusInteraction` | An interaction related to focus events. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/HoverInteraction` | An interaction related to hover events. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` | An Interaction represents transient UI state for a component, typically separate from the actual 'business' state that a component may control. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource` | InteractionSource represents a stream of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s corresponding to events emitted by a component. | Cmn |
| `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. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction` | An interaction related to press events. | Cmn |

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction.Cancel` | An interaction representing the cancellation of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction.Start` event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction.Start` | An interaction representing a drag event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction.Stop` | An interaction representing the stopping of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/DragInteraction.Start` event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/FocusInteraction.Focus` | An interaction representing a focus event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/FocusInteraction.Unfocus` | An interaction representing a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/FocusInteraction.Focus` event being released on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/HoverInteraction.Enter` | An interaction representing a hover event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/HoverInteraction.Exit` | An interaction representing a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/HoverInteraction.Enter` event being released on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Cancel` | An interaction representing the cancellation of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Press` event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Press` | An interaction representing a press event on a component. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Release` | An interaction representing the release of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/PressInteraction.Press` event on a component. | Cmn |

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/annotation/RememberInComposition https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/package-summary#MutableInteractionSource()()` Return a new `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/package-summary#MutableInteractionSource()` that can be hoisted and provided to components, allowing listening to `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` changes inside those components. | Cmn |

## Extension functions summary

|---|---|---|
| `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/package-summary#(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/package-summary#(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/package-summary#(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/package-summary#(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 |

## Top-level functions

### MutableInteractionSource

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/InteractionSource.kt+function:MutableInteractionSource) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
@RememberInComposition
fun MutableInteractionSource(): MutableInteractionSource
```

Return a new `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/package-summary#MutableInteractionSource()` that can be hoisted and provided to components, allowing listening to `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction` changes inside those components.

This should be `https://developer.android.com/reference/kotlin/androidx/compose/runtime/package-summary#remember(kotlin.Function0)`ed before it is provided to components, so it can maintain its state across compositions.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource` |   |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/package-summary#MutableInteractionSource()` |   |

## Extension functions

### 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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
@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/package-summary#(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/package-summary#(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/package-summary#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 |

### 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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
@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/package-summary#(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/package-summary#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 |

### 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) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.1.0)

```
@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/package-summary#(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 |

### 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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
@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/package-summary#(androidx.compose.ui.Modifier).clickable(kotlin.Boolean,kotlin.String,androidx.compose.ui.semantics.Role,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 |