Google is committed to advancing racial equity for Black communities. See how.

ButtonDefaults

object ButtonDefaults
kotlin.Any
   ↳ androidx.compose.material.ButtonDefaults

Contains the default values used by Button

Summary

Constants
const Float

The default color opacity used for an OutlinedButton's border color

Public methods
ButtonColors
buttonColors(backgroundColor: Color = MaterialTheme.colors.primary, disabledBackgroundColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.12f) .compositeOver(MaterialTheme.colors.surface), contentColor: Color = contentColorFor(backgroundColor), disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled))

Creates a ButtonColors that represents the default background and content colors used in a Button.

ButtonElevation
elevation(defaultElevation: Dp = 2.dp, pressedElevation: Dp = 8.dp, disabledElevation: Dp = 0.dp)

Creates a ButtonElevation that will animate between the provided values according to the Material specification for a Button.

ButtonColors
outlinedButtonColors(backgroundColor: Color = MaterialTheme.colors.surface, contentColor: Color = MaterialTheme.colors.primary, disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled))

Creates a ButtonColors that represents the default background and content colors used in an OutlinedButton.

ButtonColors
textButtonColors(backgroundColor: Color = Color.Transparent, contentColor: Color = MaterialTheme.colors.primary, disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled))

Creates a ButtonColors that represents the default background and content colors used in a TextButton.

Properties
PaddingValues

The default content padding used by Button

Dp

The default size of the icon when used inside a Button.

Dp

The default size of the spacing between an icon and a text when they used inside a Button.

Dp

The default min width applied for the Button.

Dp

The default min width applied for the Button.

Dp

The default OutlinedButton's border size

PaddingValues

The default content padding used by TextButton

BorderStroke

The default disabled content color used by all types of Buttons

Constants

OutlinedBorderOpacity

const val OutlinedBorderOpacity: Float

The default color opacity used for an OutlinedButton's border color

Value: 0.12f

Public methods

buttonColors

@Composable fun buttonColors(
    backgroundColor: Color = MaterialTheme.colors.primary,
    disabledBackgroundColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.12f) .compositeOver(MaterialTheme.colors.surface),
    contentColor: Color = contentColorFor(backgroundColor),
    disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors used in a Button.

Parameters
backgroundColor: Color = MaterialTheme.colors.primary the background color of this Button when enabled
disabledBackgroundColor: Color = MaterialTheme.colors.onSurface.copy(alpha = 0.12f) .compositeOver(MaterialTheme.colors.surface) the background color of this Button when not enabled
contentColor: Color = contentColorFor(backgroundColor) the content color of this Button when enabled
disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled) the content color of this Button when not enabled

elevation

@Composable fun elevation(
    defaultElevation: Dp = 2.dp,
    pressedElevation: Dp = 8.dp,
    disabledElevation: Dp = 0.dp
): ButtonElevation

Creates a ButtonElevation that will animate between the provided values according to the Material specification for a Button.

Parameters
defaultElevation: Dp = 2.dp the elevation to use when the Button is enabled, and has no other Interactions.
pressedElevation: Dp = 8.dp the elevation to use when the Button is enabled and is Interaction.Pressed.
disabledElevation: Dp = 0.dp the elevation to use when the Button is not enabled.

outlinedButtonColors

@Composable fun outlinedButtonColors(
    backgroundColor: Color = MaterialTheme.colors.surface,
    contentColor: Color = MaterialTheme.colors.primary,
    disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors used in an OutlinedButton.

Parameters
backgroundColor: Color = MaterialTheme.colors.surface the background color of this OutlinedButton
contentColor: Color = MaterialTheme.colors.primary the content color of this OutlinedButton when enabled
disabledContentColor: Color = MaterialTheme.colors.onSurface .copy(alpha = ContentAlpha.disabled) the content color of this OutlinedButton when not enabled

textButtonColors

@Composable fun textButtonColors(
    backgroundColor: Color = Color.Transparent,
    contentColor: Color = MaterialTheme.colors.primary