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

ButtonConstants

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

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
defaultButtonColors(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
defaultElevation(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
defaultOutlinedButtonColors(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
defaultTextButtonColors(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.

PaddingValues

The default content padding used by TextButton

Dp

The default OutlinedButton's border size

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

defaultButtonColors

@Composable fun defaultButtonColors(
    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

defaultElevation

@Composable fun defaultElevation(
    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.

defaultOutlinedButtonColors

@Composable fun defaultOutlinedButtonColors(
    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

defaultTextButtonColors

@Composable fun defaultTextButtonColors(
    backgroundColor: Color = Color.Transparent,
    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 a TextButton.

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

Properties

DefaultContentPadding

val DefaultContentPadding: PaddingValues

The default content padding used by Button

DefaultIconSize

val DefaultIconSize: Dp

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

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.Icon
import androidx.compose.material.Text

Button(onClick = { /* Do something! */ }) {
    Icon(Icons.Filled.Favorite, Modifier.size(ButtonConstants.DefaultIconSize))
    Spacer(Modifier.size(ButtonConstants.DefaultIconSpacing))
    Text("Like")
}

DefaultIconSpacing

val DefaultIconSpacing: Dp

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

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button
import androidx.compose.material.Icon
import androidx.compose.material.Text

Button(onClick = { /* Do something! */ }) {
    Icon(Icons.Filled.Favorite, Modifier.size(ButtonConstants.DefaultIconSize))
    Spacer(Modifier.size(ButtonConstants.DefaultIconSpacing))
    Text("Like")
}

DefaultMinHeight

val DefaultMinHeight: Dp

The default min width applied for the Button. Note that you can override it by applying Modifier.heightIn directly on Button.

DefaultMinWidth

val DefaultMinWidth: Dp

The default min width applied for the Button. Note that you can override it by applying Modifier.widthIn directly on Button.

DefaultTextContentPadding

val DefaultTextContentPadding: PaddingValues

The default content padding used by TextButton

OutlinedBorderSize

val OutlinedBorderSize: Dp

The default OutlinedButton's border size

defaultOutlinedBorder

@Composable val defaultOutlinedBorder: BorderStroke

The default disabled content color used by all types of Buttons