object ButtonDefaults


Contains the default values used by Button

Summary

Public functions

ButtonColors

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

ButtonColors
@Composable
buttonColors(
    containerColor: Color,
    contentColor: Color,
    secondaryContentColor: Color,
    iconColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color,
    disabledSecondaryContentColor: Color,
    disabledIconColor: Color
)

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

ButtonColors

Creates a ButtonColors with transparent background, the defaults for low emphasis buttons like ChildButton.

ButtonColors
@Composable
childButtonColors(
    contentColor: Color,
    secondaryContentColor: Color,
    iconColor: Color,
    disabledContentColor: Color,
    disabledSecondaryContentColor: Color,
    disabledIconColor: Color
)

Creates a ButtonColors with transparent background, the defaults for low emphasis buttons like ChildButton.

ButtonColors

Creates a ButtonColors with a muted background and contrasting content color, the defaults for medium emphasis buttons like FilledTonalButton.

ButtonColors
@Composable
filledTonalButtonColors(
    containerColor: Color,
    contentColor: Color,
    secondaryContentColor: Color,
    iconColor: Color,
    disabledContainerColor: Color,
    disabledContentColor: Color,
    disabledSecondaryContentColor: Color,
    disabledIconColor: Color
)

Creates a ButtonColors with a muted background and contrasting content color, the defaults for medium emphasis buttons like FilledTonalButton.

ButtonColors
@Composable
imageBackgroundButtonColors(
    backgroundImagePainter: Painter,
    backgroundImageScrimBrush: Brush,
    contentColor: Color,
    secondaryContentColor: Color,
    iconColor: Color,
    disabledContentColor: Color,
    disabledSecondaryContentColor: Color,
    disabledIconColor: Color
)

Creates a ButtonColors for a Button with an image background, typically with a scrim over the image to ensure that the content is visible.

BorderStroke
@Composable
outlinedButtonBorder(
    enabled: Boolean,
    borderColor: Color,
    disabledBorderColor: Color,
    borderWidth: Dp
)

Creates a BorderStroke, such as for an OutlinedButton

ButtonColors

Creates a ButtonColors with a transparent background (typically paired with ButtonDefaults.outlinedButtonBorder), the defaults for medium emphasis buttons like OutlinedButton, for important, non-primary actions that need attention.

ButtonColors
@Composable
outlinedButtonColors(
    contentColor: Color,
    secondaryContentColor: Color,
    iconColor: Color,
    disabledContentColor: Color,
    disabledSecondaryContentColor: Color,
    disabledIconColor: Color
)

Creates a ButtonColors with a transparent background (typically paired with ButtonDefaults.outlinedButtonBorder), the defaults for medium emphasis buttons like OutlinedButton, for important, non-primary actions that need attention.

Public properties

Dp
Dp
PaddingValues

The default content padding used by CompactButton

Dp

The height applied for the CompactButton.

Dp
PaddingValues

The default padding to be provided around a CompactButton in order to ensure that its tappable area meets minimum UX guidance.

Dp
PaddingValues

The default content padding used by Button

Dp

The default height applied for the Button.

Dp

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

Dp

The size of the icon when used inside a Large "Avatar" Button.

Dp

The size of the icon when used inside a "CompactButton.

Public functions

buttonColors

Added in 1.0.0-alpha21
@Composable
fun buttonColors(): ButtonColors

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

buttonColors

@Composable
fun buttonColors(
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified,
    secondaryContentColor: Color = Color.Unspecified,
    iconColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified,
    disabledSecondaryContentColor: Color = Color.Unspecified,
    disabledIconColor: Color = Color.Unspecified
): ButtonColors

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

Parameters
containerColor: Color = Color.Unspecified

The background color of this Button when enabled

contentColor: Color = Color.Unspecified

The content color of this Button when enabled

secondaryContentColor: Color = Color.Unspecified

The content color of this Button when enabled

iconColor: Color = Color.Unspecified

The content color of this Button when enabled

disabledContainerColor: Color = Color.Unspecified

The background color of this Button when not enabled

disabledContentColor: Color = Color.Unspecified

The content color of this Button when not enabled

disabledSecondaryContentColor: Color = Color.Unspecified

The content color of this Button when not enabled

disabledIconColor: Color = Color.Unspecified

The content color of this Button when not enabled

childButtonColors

Added in 1.0.0-alpha21
@Composable
fun childButtonColors(): ButtonColors

Creates a ButtonColors with transparent background, the defaults for low emphasis buttons like ChildButton. Use childButtonColors for optional or supplementary actions with the least amount of prominence.

If a button is disabled then the content will have an alpha(DisabledContentAlpha) value applied and container will have an alpha(DisabledContainerAlpha) value applied.

childButtonColors

@Composable
fun childButtonColors(
    contentColor: Color = Color.Unspecified,
    secondaryContentColor: Color = Color.Unspecified,
    iconColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified,
    disabledSecondaryContentColor: Color = Color.Unspecified,
    disabledIconColor: Color = Color.Unspecified
): ButtonColors

Creates a ButtonColors with transparent background, the defaults for low emphasis buttons like ChildButton. Use childButtonColors for optional or supplementary actions with the least amount of prominence.

If a button is disabled then the content will have an alpha(DisabledContentAlpha) value applied and container will have an alpha(DisabledContainerAlpha) value applied.

Parameters
contentColor: Color = Color.Unspecified

The content color of this Button when enabled

secondaryContentColor: Color = Color.Unspecified

The secondary content color of this Button when enabled, used for secondaryLabel content

iconColor: Color = Color.Unspecified

The icon color of this Button when enabled, used for icon content

disabledContentColor: Color = Color.Unspecified

The content color of this Button when not enabled

disabledSecondaryContentColor: Color = Color.Unspecified

The secondary content color of this Button when not enabled

disabledIconColor: Color = Color.Unspecified

The content color of this Button when not enabled

filledTonalButtonColors

Added in 1.0.0-alpha21
@Composable
fun filledTonalButtonColors(): ButtonColors

Creates a ButtonColors with a muted background and contrasting content color, the defaults for medium emphasis buttons like FilledTonalButton. Use filledTonalButtonColors for important actions that don't distract from other onscreen elements, such as final or unblocking actions in a flow with less emphasis than buttonColors.

If a button is disabled then the content will have an alpha(DisabledContentAlpha) value applied and container will have alpha (DisabledContainerAlpha) value applied.

filledTonalButtonColors

@Composable
fun filledTonalButtonColors(
    containerColor: Color = Color.Unspecified,
    contentColor: Color = Color.Unspecified,
    secondaryContentColor: Color = Color.Unspecified,
    iconColor: Color = Color.Unspecified,
    disabledContainerColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified,
    disabledSecondaryContentColor: Color = Color.Unspecified,
    disabledIconColor: Color = Color.Unspecified
): ButtonColors

Creates a ButtonColors with a muted background and contrasting content color, the defaults for medium emphasis buttons like FilledTonalButton. Use filledTonalButtonColors for important actions that don't distract from other onscreen elements, such as final or unblocking actions in a flow with less emphasis than buttonColors.

If a button is disabled then the content will have an alpha(DisabledContentAlpha) value applied and container will have alpha (DisabledContainerAlpha) value applied.

Parameters
containerColor: Color = Color.Unspecified

The background color of this Button when enabled

contentColor: Color = Color.Unspecified

The content color of this Button when enabled

secondaryContentColor: Color = Color.Unspecified

The secondary content color of this Button when enabled, used for secondaryLabel content

iconColor: Color = Color.Unspecified

The icon color of this Button when enabled, used for icon content

disabledContainerColor: Color = Color.Unspecified

The background color of this Button when not enabled

disabledContentColor: Color = Color.Unspecified

The content color of this Button when not enabled

disabledSecondaryContentColor: Color = Color.Unspecified

The secondary content color of this Button when not enabled

disabledIconColor: Color = Color.Unspecified

The content color of this Button when not enabled

imageBackgroundButtonColors

@Composable
fun imageBackgroundButtonColors(
    backgroundImagePainter: Painter,
    backgroundImageScrimBrush: Brush = Brush.linearGradient( colors = listOf( ImageButtonTokens.BackgroundImageGradientColor.value.copy( alpha = ImageButtonTokens.GradientStartOpacity ), ImageButtonTokens.BackgroundImageGradientColor.value.copy( alpha = ImageButtonTokens.GradientEndOpacity ) ) ),
    contentColor: Color = ImageButtonTokens.ContentColor.value,
    secondaryContentColor: Color = ImageButtonTokens.SecondaryContentColor.value,
    iconColor: Color = ImageButtonTokens.IconColor.value,
    disabledContentColor: Color = ImageButtonTokens.DisabledContentColor.value.toDisabledColor( disabledAlpha = ImageButtonTokens.DisabledContentOpacity ),
    disabledSecondaryContentColor: Color = ImageButtonTokens.DisabledContentColor.value .toDisabledColor( disabledAlpha = ImageButtonTokens.DisabledContentOpacity ),
    disabledIconColor: Color = ImageButtonTokens.DisabledContentColor.value.toDisabledColor( disabledAlpha = ImageButtonTokens.DisabledContentOpacity )
): ButtonColors

Creates a ButtonColors for a Button with an image background, typically with a scrim over the image to ensure that the content is visible. Uses a default content color of ColorScheme.onSurface.

Parameters
backgroundImagePainter: Painter

The Painter to use to draw the background of the Button

backgroundImageScrimBrush: Brush = Brush.linearGradient( colors = listOf( ImageButtonTokens.BackgroundImageGradientColor.value.copy( alpha = ImageButtonTokens.GradientStartOpacity ), ImageButtonTokens.BackgroundImageGradientColor.value.copy( alpha = ImageButtonTokens.GradientEndOpacity ) ) )

The Brush to use to paint a scrim over the background image to ensure that any text drawn over the image is legible

contentColor: Color = ImageButtonTokens.ContentColor.value

The content color of this Button when enabled

secondaryContentColor: Color = ImageButtonTokens.SecondaryContentColor.value

The secondary content color of this Button when enabled, used for secondaryLabel content

iconColor: Color = ImageButtonTokens.IconColor.value

The icon color of this Button when enabled, used for icon content

disabledContentColor: Color = ImageButtonTokens.DisabledContentColor.value.toDisabledColor( disabledAlpha = ImageButtonTokens.DisabledContentOpacity )

The content color of this Button when disabled

disabledSecondaryContentColor: Color = ImageButtonTokens.DisabledContentColor.value .toDisabledColor( disabledAlpha = ImageButtonTokens.DisabledContentOpacity )

The secondary content color of this Button when disabled, used for secondary label content

disabledIconColor: Color = ImageButtonTokens.DisabledContentColor.value.toDisabledColor( disabledAlpha = ImageButtonTokens.DisabledContentOpacity )

The icon color of this Button when disabled, used for icon content

outlinedButtonBorder

@Composable
fun outlinedButtonBorder(
    enabled: Boolean,
    borderColor: Color = OutlinedButtonTokens.ContainerBorderColor.value,
    disabledBorderColor: Color = OutlinedButtonTokens.DisabledContainerBorderColor.value.toDisabledColor( disabledAlpha = OutlinedButtonTokens.DisabledContainerBorderOpacity ),
    borderWidth: Dp = OutlinedButtonTokens.ContainerBorderWidth
): BorderStroke

Creates a BorderStroke, such as for an OutlinedButton

Parameters
borderColor: Color = OutlinedButtonTokens.ContainerBorderColor.value

The color to use for the border for this outline when enabled

disabledBorderColor: Color = OutlinedButtonTokens.DisabledContainerBorderColor.value.toDisabledColor( disabledAlpha = OutlinedButtonTokens.DisabledContainerBorderOpacity )

The color to use for the border for this outline when disabled

borderWidth: Dp = OutlinedButtonTokens.ContainerBorderWidth

The width to use for the border for this outline. It is strongly recommended to use the default width as this outline is a key characteristic of Wear Material3.

outlinedButtonColors

Added in 1.0.0-alpha21
@Composable
fun outlinedButtonColors(): ButtonColors

Creates a ButtonColors with a transparent background (typically paired with ButtonDefaults.outlinedButtonBorder), the defaults for medium emphasis buttons like OutlinedButton, for important, non-primary actions that need attention.

If a button is disabled then the content will have an alpha(DisabledContentAlpha) value applied and container will have an alpha(DisabledContainerAlpha) applied.

outlinedButtonColors

@Composable
fun outlinedButtonColors(
    contentColor: Color = Color.Unspecified,
    secondaryContentColor: Color = Color.Unspecified,
    iconColor: Color = Color.Unspecified,
    disabledContentColor: Color = Color.Unspecified,
    disabledSecondaryContentColor: Color = Color.Unspecified,
    disabledIconColor: Color = Color.Unspecified
): ButtonColors

Creates a ButtonColors with a transparent background (typically paired with ButtonDefaults.outlinedButtonBorder), the defaults for medium emphasis buttons like OutlinedButton, for important, non-primary actions that need attention.

If a button is disabled then the content will have an alpha(DisabledContentAlpha) value applied and container will have an alpha(DisabledContainerAlpha) applied.

Parameters
contentColor: Color = Color.Unspecified

The content color of this Button when enabled

secondaryContentColor: Color = Color.Unspecified

The secondary content color of this Button when enabled, used for secondaryLabel content

iconColor: Color = Color.Unspecified

The icon color of this Button when enabled, used for icon content

disabledContentColor: Color = Color.Unspecified

The content color of this Button when not enabled

disabledSecondaryContentColor: Color = Color.Unspecified

The secondary content color of this Button when not enabled

disabledIconColor: Color = Color.Unspecified

The content color of this Button when not enabled

Public properties

ButtonHorizontalPadding

Added in 1.0.0-alpha21
val ButtonHorizontalPaddingDp

ButtonVerticalPadding

Added in 1.0.0-alpha21
val ButtonVerticalPaddingDp

CompactButtonContentPadding

Added in 1.0.0-alpha21
val CompactButtonContentPaddingPaddingValues

The default content padding used by CompactButton

CompactButtonHeight

Added in 1.0.0-alpha21
val CompactButtonHeightDp

The height applied for the CompactButton. This includes a visible button height of 32.dp and 8.dp of padding above and below the button in order to meet accessibility guidelines that request a minimum of 48.dp height and width of tappable area.

Note that you can override it by adjusting Modifier.height and Modifier.padding directly on CompactButton.

CompactButtonHorizontalPadding

Added in 1.0.0-alpha21
val CompactButtonHorizontalPaddingDp

CompactButtonTapTargetPadding

Added in 1.0.0-alpha21
val CompactButtonTapTargetPaddingPaddingValues

The default padding to be provided around a CompactButton in order to ensure that its tappable area meets minimum UX guidance.

CompactButtonVerticalPadding

Added in 1.0.0-alpha21
val CompactButtonVerticalPaddingDp

ContentPadding

Added in 1.0.0-alpha21
val ContentPaddingPaddingValues

The default content padding used by Button

Height

Added in 1.0.0-alpha21
val HeightDp

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

IconSize

Added in 1.0.0-alpha21
val IconSizeDp

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

LargeIconSize

Added in 1.0.0-alpha21
val LargeIconSizeDp

The size of the icon when used inside a Large "Avatar" Button.

SmallIconSize

Added in 1.0.0-alpha21
val SmallIconSizeDp

The size of the icon when used inside a "CompactButton.