# ComposableTarget

Artifact: [androidx.compose.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime) [View Source](https://cs.android.com/search?q=file:androidx/compose/runtime/ComposableTarget.kt+class:androidx.compose.runtime.ComposableTarget) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.2.0) Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  @Repeatable
  @Retention(value = AnnotationRetention.BINARY)
  @Target(allowedTargets = [AnnotationTarget.FILE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER])
  annotation ComposableTarget
  ```

*** ** * ** ***

This annotation may be applied to a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function one or more times to declare that the function expects an applier whose name is the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget#(kotlin.String)` argument of any of the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget` annotations marking the function.

Beware that only version 2.5.0 and newer of the Compose compiler plugin correctly acknowledge multiple applications of this annotation on a single function. Older versions of the Compose compiler plugin will only acknowledge the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget` annotation on a function that comes earliest in the file.

The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget#(kotlin.String)` name can be an arbitrary string but is expected to be the fully qualified name of a class that is annotated by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTargetMarker`. The `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget#(kotlin.String)` name is used in diagnostic messages unless it refers to a class annotated by `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTargetMarker`, then the corresponding `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTargetMarker#description()` is used instead.

The Compose compiler plugin can, in most cases, infer the necessary `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget` annotations, or equivalent pair of `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableInferredTarget` and `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableInferredTargetConstraints` annotations, to apply to a composable function. Some insight into how this inference works is provided below.

If it has been declared or inferred that a composable function expects an applier with precisely one allowed name, then that function is considered to be in the group of functions corresponding to that name. If a composable function calls another composable function, then both must be of the same group of composable functions. This means that if it has been determined that a called function is part of a certain group, then the function that calls it must also be in the same group. If a function calls another function of a different group, then the Compose compiler plugin will generate a diagnostic message describing which group was received and which group was expected.

If it has been declared or inferred that a composable function expects an applier whose name is in a set of allowed names, then that function is considered to be constrained to that set of names. As mentioned above, if a composable function calls another composable function then both must be of the same group of composable functions. This means that if it has been determined that a called function is constrained to a set of names, then the function that calls it must be 1) part of the group of functions corresponding to one of the names in that set, or 2) constrained to a set of names that has at least one name in common with that set. If the calling function does not fit in either of those two categories, then the Compose compiler plugin will generate a diagnostic message describing the incompatibility between the appliers expected by the two functions.

If an `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier` is supplied to a composable function at runtime that the function did not expect, an error will be reported. This annotation, and the corresponding validation performed by the Compose compiler plugin, can detect incompatibilities at compile time, and issue a diagnostic message when calling a `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` function will result in the `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier` check failing. This makes it possible to eliminate the possibility of encountering runtime `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Applier` incompatibilities.

The Compose compiler plugin can infer the necessary annotations to apply to a composable function in most cases. However, there are certain categories of functions that need to be annotated explicitly by the user to indicate that they are part of a certain group or constrained to a certain set of names. They are listed below:

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` functions that call `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposeNode.composable#ComposeNode(kotlin.Function0,kotlin.Function1)` directly

- Abstract methods, such as interface functions (which do not contain a body from which the plugin can infer the necessary annotations)

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` lambdas used in sub-composition

- `https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable` lambdas that are stored in class fields or global variables

Functions in the above categories that are not explicitly annotated will be ignored by the Compose compiler plugin, and diagnostics will not be emitted when those functions are called incorrectly.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget#ComposableTarget(kotlin.String)(applier: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTarget#applier()` The applier name used during composable call checking. | Cmn |

## Public constructors

### ComposableTarget

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

```
ComposableTarget(applier: String)
```

| Parameters |
|---|---|
| `applier: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The applier name used during composable call checking. This can be an arbitrary string value but is expected to be a fully qualified name of a class that is marked with `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTargetMarker`. |

## Public properties

### applier

Cmn

```
val applier: String
```

The applier name used during composable call checking. This can be an arbitrary string value but is expected to be a fully qualified name of a class that is marked with `https://developer.android.com/reference/kotlin/androidx/compose/runtime/ComposableTargetMarker`.