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
AnimatedValue<Dp, AnimationVector1D>
defaultAnimatedElevation(interactionState: InteractionState, enabled: Boolean, defaultElevation: Dp = 2.dp, pressedElevation: Dp = 8.dp, disabledElevation: Dp = 0.dp)

Represents the default elevation for a button in different Interactions, and how the elevation animates between them.

Color
defaultButtonBackgroundColor(enabled: Boolean, defaultColor: Color = MaterialTheme.colors.primary, disabledColor: Color = defaultDisabledBackgroundColor)

Returns the recommended background color for a Button based on its current state.

Color
defaultButtonContentColor(enabled: Boolean, defaultColor: Color, disabledColor: Color = defaultDisabledContentColor)

Returns the recommended content color for a Button based on its current state.

Color
defaultOutlinedButtonContentColor(enabled: Boolean, defaultColor: Color = MaterialTheme.colors.primary, disabledColor: Color = defaultDisabledContentColor)

Returns the recommended content color for an OutlinedButton based on its current state.

Color
defaultTextButtonContentColor(enabled: Boolean, defaultColor: Color = MaterialTheme.colors.primary, disabledColor: Color = defaultDisabledContentColor)

Returns the recommended content color for a TextButton based on its current state.

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

Color

The default disabled background color used by Button

Color

The default disabled content color used by all types of Buttons

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

defaultAnimatedElevation

@Composable fun defaultAnimatedElevation(
    interactionState: InteractionState,
    enabled: Boolean,
    defaultElevation: Dp = 2.dp,
    pressedElevation: Dp = 8.dp,
    disabledElevation: Dp = 0.dp
): AnimatedValue<Dp, AnimationVector1D>

Represents the default elevation for a button in different Interactions, and how the elevation animates between them.

Parameters
interactionState: InteractionState the InteractionState for this Button, representing the current visual state, such as whether it is Interaction.Pressed or not.
enabled: Boolean whether the Button is enabled or not. If the Button is disabled then disabledElevation will always be used, regardless of the state of interactionState.
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.

defaultButtonBackgroundColor

@Composable fun defaultButtonBackgroundColor(
    enabled: Boolean,
    defaultColor: Color = MaterialTheme.colors.primary,
    disabledColor: Color = defaultDisabledBackgroundColor
): Color

Returns the recommended background color for a Button based on its current state.

Parameters
enabled: Boolean whether the Button is enabled or not
defaultColor: Color = MaterialTheme.colors.primary the color to use when enabled
disabledColor: Color = defaultDisabledBackgroundColor the color to use when disabled

defaultButtonContentColor

@Composable fun defaultButtonContentColor(
    enabled: Boolean,
    defaultColor: Color,
    disabledColor: Color = defaultDisabledContentColor
): Color

Returns the recommended content color for a Button based on its current state.

Parameters
defaultColor: Color the content color to use when enabled. This should typically be contentColorFor the background color provided to the Button.
enabled: Boolean whether the Button is enabled or not
disabledColor: Color = defaultDisabledContentColor the content color to use when disabled

defaultOutlinedButtonContentColor

@Composable fun defaultOutlinedButtonContentColor(
    enabled: Boolean,
    defaultColor: Color = MaterialTheme.colors.primary,
    disabledColor: Color = defaultDisabledContentColor
): Color

Returns the recommended content color for an OutlinedButton based on its current state.

Parameters
enabled: Boolean whether the OutlinedButton is enabled or not
defaultColor: Color = MaterialTheme.colors.primary the content color to use when enabled
disabledColor: Color = defaultDisabledContentColor the content color to use when disabled

defaultTextButtonContentColor

@Composable fun defaultTextButtonContentColor(
    enabled: Boolean,
    defaultColor: Color = MaterialTheme.colors.primary,
    disabledColor: Color = defaultDisabledContentColor
): Color

Returns the recommended content color for a TextButton based on its current state.

Parameters
enabled: Boolean whether the TextButton is enabled or not
defaultColor: Color = MaterialTheme.colors.primary the content color to use when enabled
disabledColor: Color = defaultDisabledContentColor the content color to use when disabled

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.Icon
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button

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.Icon
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.Button

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

defaultDisabledBackgroundColor

@Composable val defaultDisabledBackgroundColor: Color

The default disabled background color used by Button

defaultDisabledContentColor

@Composable val defaultDisabledContentColor: Color

The default disabled content color used by all types of Buttons

defaultOutlinedBorder

@Composable val defaultOutlinedBorder: BorderStroke

The default disabled content color used by all types of Buttons