# CompactButton

## Functions summary

|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/wear/compose/material/CompactButton.composable#CompactButton(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)( onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier, enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, colors: https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonColors, backgroundPadding: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, interactionSource: https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource?, shape: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Shape, border: https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonBorder, content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/BoxScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Wear Material `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/CompactButton.composable#CompactButton(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)` that offers a single slot to take any content (text, icon or image). |

## Functions

### CompactButton

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/Button.kt+function:CompactButton)

```
@Composable
fun CompactButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    colors: ButtonColors = ButtonDefaults.primaryButtonColors(),
    backgroundPadding: Dp = ButtonDefaults.CompactButtonBackgroundPadding,
    interactionSource: MutableInteractionSource? = null,
    shape: Shape = CircleShape,
    border: ButtonBorder = ButtonDefaults.buttonBorder(),
    content: @Composable BoxScope.() -> Unit
): Unit
```

Wear Material `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/CompactButton.composable#CompactButton(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)` that offers a single slot to take any content (text, icon or image).

The `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/CompactButton.composable#CompactButton(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)` has background size `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#ExtraSmallButtonSize()`. There is an optional transparent padding around the background, defaulted to `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#CompactButtonBackgroundPadding()`, which increases the clickable area. Icon content should have size `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#SmallIconSize()`.

The recommended set of `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonColors` styles can be obtained from `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults`, e.g. `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#primaryButtonColors(androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color)` to get a color scheme for a primary `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)` which by default will have a solid background of `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Colors#primary()` and content color of `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/Colors#onPrimary()`.

`https://developer.android.com/reference/kotlin/androidx/wear/compose/material/CompactButton.composable#CompactButton(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)`s can be enabled or disabled. A disabled button will not respond to click events.

Example usage:

```kotlin
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.wear.compose.material.Button
import androidx.wear.compose.material.ButtonDefaults
import androidx.wear.compose.material.CompactButton
import androidx.wear.compose.material.Icon

CompactButton(onClick = { /* Do something */ }, enabled = true) {
    Icon(
        painter = painterResource(id = R.drawable.ic_airplanemode_active_24px),
        contentDescription = "airplane",
        modifier =
            Modifier.size(ButtonDefaults.SmallIconSize)
                .wrapContentSize(align = Alignment.Center),
    )
}
```

For more information, see the [Buttons](https://developer.android.com/training/wearables/components/buttons) guide.

| Parameters |
|---|---|
| `onClick: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Will be called when the user clicks the button. |
| `modifier: https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier = Modifier` | Modifier to be applied to the button. |
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | Controls the enabled state of the button. When `false`, this button will not be clickable. |
| `colors: https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonColors = ButtonDefaults.primaryButtonColors()` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonColors` that will be used to resolve the background and content color for this button in different states. See `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#buttonColors(androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color)`. |
| `backgroundPadding: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp = ButtonDefaults.CompactButtonBackgroundPadding` | Increases the transparent clickable area around the background, defaults to `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#CompactButtonBackgroundPadding()` |
| `interactionSource: https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource? = null` | an optional hoisted `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/MutableInteractionSource` for observing and emitting `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/Interaction`s for this button. You can use this to change the button's appearance or preview the button in different states. Note that if `null` is provided, interactions will still happen internally. |
| `shape: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Shape = CircleShape` | Defines the button's shape. It is strongly recommended to use the default as this shape is a key characteristic of the Wear Material Theme. |
| `border: https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonBorder = ButtonDefaults.buttonBorder()` | `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonBorder` that will be used to resolve the button border in different states. See `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/ButtonDefaults#outlinedButtonBorder(androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp)`. |
| `content: @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/BoxScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | The content displayed on the `https://developer.android.com/reference/kotlin/androidx/wear/compose/material/CompactButton.composable#CompactButton(kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.wear.compose.material.ButtonColors,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,androidx.compose.ui.graphics.Shape,androidx.wear.compose.material.ButtonBorder,kotlin.Function1)` such as text, icon or image. |