# contentColorFor

## Functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/wear/compose/material/contentColorFor.composable#contentColorFor(androidx.compose.ui.graphics.Color)(backgroundColor: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color)` The Material color system contains pairs of colors that are typically used for the background and content color inside a component. |

## Functions

### contentColorFor

Artifact: [androidx.wear.compose:compose-material](https://developer.android.com/jetpack/androidx/releases/wear-compose) [View Source](https://cs.android.com/search?q=file:androidx/wear/compose/material/Colors.kt+function:contentColorFor) Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/wear-compose#1.6.0)

```
@Composable
fun contentColorFor(backgroundColor: Color): Color
```

The Material color system contains pairs of colors that are typically used for the background and content color inside a component. For example, a `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Button.composable#Button(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)` typically uses `primary` for its background, and `onPrimary` for the color of its content (usually text or iconography).

This function tries to match the provided `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#contentColorFor(androidx.compose.ui.graphics.Color)` to a 'background' color in this `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Colors`, and then will return the corresponding color used for content. For example, when `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#contentColorFor(androidx.compose.ui.graphics.Color)` is `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Colors#primary()`, this will return `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Colors#onPrimary()`.

If `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#contentColorFor(androidx.compose.ui.graphics.Color)` does not match a background color in the theme, this will return the current value of `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#LocalContentColor()` as a best-effort color.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Color` | the matching content color for `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#contentColorFor(androidx.compose.ui.graphics.Color)`. If `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#contentColorFor(androidx.compose.ui.graphics.Color)` is not present in the theme's `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Colors`, then returns the current value of `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#LocalContentColor()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/package-summary#(androidx.wear.compose.material.Colors).contentColorFor(androidx.compose.ui.graphics.Color)` |   |