Object

ButtonDefaults

Contains the default values used by Button

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Common
object ButtonDefaults

Contains the default values used by Button

Properties

Common
val ContentPadding =
    PaddingValues(
        start = ButtonHorizontalPadding,
        top = ButtonVerticalPadding,
        end = ButtonHorizontalPadding,
        bottom = ButtonVerticalPadding,
    )

The default content padding used by Button

Common
val MinWidth = 64.dp

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

Common
val MinHeight = 36.dp

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

Common
val IconSize = 18.dp

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

Common
val IconSpacing = 8.dp

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

Common
const val OutlinedBorderOpacity = 0.12f

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

Common
val OutlinedBorderSize = 1.dp

The default OutlinedButton's border size

Common
val outlinedBorder: BorderStroke

The default disabled content color used by all types of Buttons

Common
val TextButtonContentPadding =
    PaddingValues(
        start = TextButtonHorizontalPadding,
        top = ContentPadding.calculateTopPadding(),
        end = TextButtonHorizontalPadding,
        bottom = ContentPadding.calculateBottomPadding(),
    )

The default content padding used by TextButton

Functions

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 the elevation to use when the Button is enabled, and has no other Interactions.
pressedElevation the elevation to use when the Button is enabled and is pressed.
disabledElevation the elevation to use when the Button is not enabled.

elevation

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

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

Parameters

defaultElevation the elevation to use when the Button is enabled, and has no other Interactions.
pressedElevation the elevation to use when the Button is enabled and is pressed.
disabledElevation the elevation to use when the Button is not enabled.
hoveredElevation the elevation to use when the Button is enabled and is hovered.
focusedElevation the elevation to use when the Button is enabled and is focused.

buttonColors

@Composable
    fun buttonColors(
        backgroundColor: Color = MaterialTheme.colors.primary,
        contentColor: Color = contentColorFor(backgroundColor),
        disabledBackgroundColor: Color =
            MaterialTheme.colors.onSurface
                .copy(alpha = 0.12f)
                .compositeOver(MaterialTheme.colors.surface),
        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 the background color of this Button when enabled
contentColor the content color of this Button when enabled
disabledBackgroundColor the background color of this Button when not enabled
disabledContentColor the content color of this Button when 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 the background color of this OutlinedButton
contentColor the content color of this OutlinedButton when enabled
disabledContentColor the content color of this OutlinedButton when not enabled

textButtonColors

@Composable
    fun textButtonColors(
        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 the background color of this TextButton
contentColor the content color of this TextButton when enabled
disabledContentColor the content color of this TextButton when not enabled