ButtonDefaults

object ButtonDefaults


Contains the default values used by Button.

Summary

Public functions

ButtonBorder
@Composable
buttonBorder(
    borderStroke: BorderStroke?,
    disabledBorderStroke: BorderStroke?
)

Creates a ButtonBorder for the default border used in most Button

ButtonColors
@Composable
buttonColors(
    backgroundColor: Color,
    contentColor: Color,
    disabledBackgroundColor: Color,
    disabledContentColor: Color
)

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

ButtonColors

Creates a ButtonColors that represents the content colors for an icon-only Button.

ButtonBorder
@Composable
outlinedButtonBorder(
    borderColor: Color,
    disabledBorderColor: Color,
    borderWidth: Dp
)

Creates a ButtonBorder for the OutlinedButton

ButtonColors

Creates a ButtonColors that represents the content colors for an OutlinedButton.

ButtonColors
@Composable
primaryButtonColors(backgroundColor: Color, contentColor: Color)

Creates a ButtonColors that represents the default background and content colors for a primary Button.

ButtonColors
@Composable
secondaryButtonColors(backgroundColor: Color, contentColor: Color)

Creates a ButtonColors that represents the default background and content colors for a secondary Button.

Public properties

Dp

The default padding for a CompactButton.

Dp

The default size applied for the Button.

Dp

The default size of an icon when used inside a default-sized Button.

Dp

The default background size of a CompactButton.

Dp

The recommended size for a large Button.

Dp

The size of an icon when used inside a large-sized Button.

Dp

The recommended size for a small Button.

Dp

The size of an icon when used inside a small-sized Button or a CompactButton.

Public functions

buttonBorder

Added in 1.1.0
@Composable
fun buttonBorder(
    borderStroke: BorderStroke? = null,
    disabledBorderStroke: BorderStroke? = borderStroke
): ButtonBorder

Creates a ButtonBorder for the default border used in most Button

Parameters
borderStroke: BorderStroke? = null

The border of this Button when enabled - or no border if null

disabledBorderStroke: BorderStroke? = borderStroke

The border of this Button when disabled - or no border if null

buttonColors

Added in 1.6.0
@Composable
fun buttonColors(
    backgroundColor: Color = MaterialTheme.colors.primary,
    contentColor: Color = contentColorFor(backgroundColor),
    disabledBackgroundColor: Color = backgroundColor.copy(alpha = ContentAlpha.disabled),
    disabledContentColor: Color = contentColor.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

contentColor: Color = contentColorFor(backgroundColor)

the content color of this Button when enabled

disabledBackgroundColor: Color = backgroundColor.copy(alpha = ContentAlpha.disabled)

the background color of this Button when not enabled

disabledContentColor: Color = contentColor.copy(alpha = ContentAlpha.disabled)

the content color of this Button when not enabled

iconButtonColors

Added in 1.6.0
@Composable
fun iconButtonColors(contentColor: Color = MaterialTheme.colors.onSurface): ButtonColors

Creates a ButtonColors that represents the content colors for an icon-only Button. If a button is disabled then the colors will have an alpha (ContentAlpha.disabled) value applied.

Parameters
contentColor: Color = MaterialTheme.colors.onSurface

The content color of this Button when enabled

outlinedButtonBorder

Added in 1.6.0
@Composable
fun outlinedButtonBorder(
    borderColor: Color = MaterialTheme.colors.primaryVariant.copy(alpha = 0.6f),
    disabledBorderColor: Color = borderColor.copy(alpha = ContentAlpha.disabled),
    borderWidth: Dp = 1.dp
): ButtonBorder

Creates a ButtonBorder for the OutlinedButton

Parameters
borderColor: Color = MaterialTheme.colors.primaryVariant.copy(alpha = 0.6f)

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

disabledBorderColor: Color = borderColor.copy(alpha = ContentAlpha.disabled)

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

borderWidth: Dp = 1.dp

The width to use for the border for this OutlinedButton

outlinedButtonColors

Added in 1.6.0
@Composable
fun outlinedButtonColors(contentColor: Color = MaterialTheme.colors.primary): ButtonColors

Creates a ButtonColors that represents the content colors for an OutlinedButton. If a button is disabled then the colors will have an alpha (ContentAlpha.disabled) value applied.

Parameters
contentColor: Color = MaterialTheme.colors.primary

The content color of this OutlinedButton when enabled

primaryButtonColors

Added in 1.6.0
@Composable
fun primaryButtonColors(
    backgroundColor: Color = MaterialTheme.colors.primary,
    contentColor: Color = contentColorFor(backgroundColor)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors for a primary Button. Primary buttons have a colored background with a contrasting content color. If a button is disabled then the colors will have an alpha (ContentAlpha.disabled) value applied.

Parameters
backgroundColor: Color = MaterialTheme.colors.primary

The background color of this Button when enabled

contentColor: Color = contentColorFor(backgroundColor)

The content color of this Button when enabled

secondaryButtonColors

Added in 1.6.0
@Composable
fun secondaryButtonColors(
    backgroundColor: Color = MaterialTheme.colors.surface,
    contentColor: Color = contentColorFor(backgroundColor)
): ButtonColors

Creates a ButtonColors that represents the default background and content colors for a secondary Button. Secondary buttons have a muted background with a contrasting content color. If a button is disabled then the colors will have an alpha (ContentAlpha.disabled) value applied.

Parameters
backgroundColor: Color = MaterialTheme.colors.surface

The background color of this Button when enabled

contentColor: Color = contentColorFor(backgroundColor)

The content color of this Button when enabled

Public properties

CompactButtonBackgroundPadding

Added in 1.0.0
val CompactButtonBackgroundPadding: Dp

The default padding for a CompactButton. This will result in a larger tap area than visible area.

DefaultButtonSize

Added in 1.0.0
val DefaultButtonSize: Dp

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

DefaultIconSize

Added in 1.0.0
val DefaultIconSize: Dp

The default size of an icon when used inside a default-sized Button.

ExtraSmallButtonSize

Added in 1.0.0
val ExtraSmallButtonSize: Dp

The default background size of a CompactButton.

LargeButtonSize

Added in 1.0.0
val LargeButtonSize: Dp

The recommended size for a large Button. You can apply this value for the size by overriding Modifier.size directly on Button.

LargeIconSize

Added in 1.0.0
val LargeIconSize: Dp

The size of an icon when used inside a large-sized Button.

SmallButtonSize

Added in 1.0.0
val SmallButtonSize: Dp

The recommended size for a small Button. You can apply this value for the size by overriding Modifier.size directly on Button.

SmallIconSize

Added in 1.0.0
val SmallIconSize: Dp

The size of an icon when used inside a small-sized Button or a CompactButton.