{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ButtonDefaults

public static class ButtonDefaults


Contains the default values used by all 5 button types.

Default values that apply to all buttons types are MinWidth, MinHeight, IconSize, and IconSpacing.

A default value that applies only to Button, ElevatedButton, FilledTonalButton, and OutlinedButton is ContentPadding.

Default values that apply only to Button are buttonColors and buttonElevation. Default values that apply only to ElevatedButton are elevatedButtonColors and elevatedButtonElevation. Default values that apply only to FilledTonalButton are filledTonalButtonColors and filledTonalButtonElevation. A default value that applies only to OutlinedButton is outlinedButtonColors. Default values that apply only to TextButton are TextButtonContentPadding and textButtonColors.

Summary

Public fields

static @NonNull ButtonDefaults

Public methods

final @NonNull ButtonColors

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

final @NonNull ButtonColors
@Composable
buttonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

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

final @NonNull ButtonElevation
@Composable
buttonElevation(
    @NonNull Dp defaultElevation,
    @NonNull Dp pressedElevation,
    @NonNull Dp focusedElevation,
    @NonNull Dp hoveredElevation,
    @NonNull Dp disabledElevation
)

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

final @NonNull ButtonColors

Creates a ButtonColors that represents the default container and content colors used in an ElevatedButton.

final @NonNull ButtonColors
@Composable
elevatedButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in an ElevatedButton.

final @NonNull ButtonElevation
@Composable
elevatedButtonElevation(
    @NonNull Dp defaultElevation,
    @NonNull Dp pressedElevation,
    @NonNull Dp focusedElevation,
    @NonNull Dp hoveredElevation,
    @NonNull Dp disabledElevation
)

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

final @NonNull ButtonColors

Creates a ButtonColors that represents the default container and content colors used in an FilledTonalButton.

final @NonNull ButtonColors
@Composable
filledTonalButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in an FilledTonalButton.

final @NonNull ButtonElevation
@Composable
filledTonalButtonElevation(
    @NonNull Dp defaultElevation,
    @NonNull Dp pressedElevation,
    @NonNull Dp focusedElevation,
    @NonNull Dp hoveredElevation,
    @NonNull Dp disabledElevation
)

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

final @NonNull PaddingValues

The default content padding used by Button that contains an Icon.

final @NonNull PaddingValues

The default content padding used by Button, ElevatedButton, FilledTonalButton, and OutlinedButton buttons.

final @NonNull Shape

Default shape for an elevated button.

final @NonNull Shape

Default shape for a filled tonal button.

final @NonNull Dp

The default size of the icon when used inside any button.

final @NonNull Dp

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

final @NonNull Dp

The default min height applied for all buttons.

final @NonNull Dp

The default min width applied for all buttons.

final @NonNull BorderStroke

The default BorderStroke used by OutlinedButton.

final @NonNull Shape

Default shape for an outlined button.

final @NonNull Shape

Default shape for a button.

final @NonNull PaddingValues

The default content padding used by TextButton.

final @NonNull PaddingValues

The default content padding used by TextButton that contains an Icon.

final @NonNull Shape

Default shape for a text button.

final @NonNull ButtonColors

Creates a ButtonColors that represents the default container and content colors used in an OutlinedButton.

final @NonNull ButtonColors
@Composable
outlinedButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in an OutlinedButton.

final @NonNull ButtonColors

Creates a ButtonColors that represents the default container and content colors used in a TextButton.

final @NonNull ButtonColors
@Composable
textButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in a TextButton.

Public fields

INSTANCE

public static @NonNull ButtonDefaults INSTANCE

Public methods

buttonColors

@Composable
public final @NonNull ButtonColors buttonColors()

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

buttonColors

@Composable
public final @NonNull ButtonColors buttonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

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

Parameters
@NonNull Color containerColor

the container color of this Button when enabled.

@NonNull Color contentColor

the content color of this Button when enabled.

@NonNull Color disabledContainerColor

the container color of this Button when not enabled.

@NonNull Color disabledContentColor

the content color of this Button when not enabled.

buttonElevation

@Composable
public final @NonNull ButtonElevation buttonElevation(
    @NonNull Dp defaultElevation,
    @NonNull Dp pressedElevation,
    @NonNull Dp focusedElevation,
    @NonNull Dp hoveredElevation,
    @NonNull Dp disabledElevation
)

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

Parameters
@NonNull Dp defaultElevation

the elevation used when the Button is enabled, and has no other Interactions.

@NonNull Dp pressedElevation

the elevation used when this Button is enabled and pressed.

@NonNull Dp focusedElevation

the elevation used when the Button is enabled and focused.

@NonNull Dp hoveredElevation

the elevation used when the Button is enabled and hovered.

@NonNull Dp disabledElevation

the elevation used when the Button is not enabled.

elevatedButtonColors

@Composable
public final @NonNull ButtonColors elevatedButtonColors()

Creates a ButtonColors that represents the default container and content colors used in an ElevatedButton.

elevatedButtonColors

@Composable
public final @NonNull ButtonColors elevatedButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in an ElevatedButton.

Parameters
@NonNull Color containerColor

the container color of this ElevatedButton when enabled

@NonNull Color contentColor

the content color of this ElevatedButton when enabled

@NonNull Color disabledContainerColor

the container color of this ElevatedButton when not enabled

@NonNull Color disabledContentColor

the content color of this ElevatedButton when not enabled

elevatedButtonElevation

@Composable
public final @NonNull ButtonElevation elevatedButtonElevation(
    @NonNull Dp defaultElevation,
    @NonNull Dp pressedElevation,
    @NonNull Dp focusedElevation,
    @NonNull Dp hoveredElevation,
    @NonNull Dp disabledElevation
)

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

Parameters
@NonNull Dp defaultElevation

the elevation used when the ElevatedButton is enabled, and has no other Interactions.

@NonNull Dp pressedElevation

the elevation used when this ElevatedButton is enabled and pressed.

@NonNull Dp focusedElevation

the elevation used when the ElevatedButton is enabled and focused.

@NonNull Dp hoveredElevation

the elevation used when the ElevatedButton is enabled and hovered.

@NonNull Dp disabledElevation

the elevation used when the ElevatedButton is not enabled.

filledTonalButtonColors

@Composable
public final @NonNull ButtonColors filledTonalButtonColors()

Creates a ButtonColors that represents the default container and content colors used in an FilledTonalButton.

filledTonalButtonColors

@Composable
public final @NonNull ButtonColors filledTonalButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in an FilledTonalButton.

Parameters
@NonNull Color containerColor

the container color of this FilledTonalButton when enabled

@NonNull Color contentColor

the content color of this FilledTonalButton when enabled

@NonNull Color disabledContainerColor

the container color of this FilledTonalButton when not enabled

@NonNull Color disabledContentColor

the content color of this FilledTonalButton when not enabled

filledTonalButtonElevation

@Composable
public final @NonNull ButtonElevation filledTonalButtonElevation(
    @NonNull Dp defaultElevation,
    @NonNull Dp pressedElevation,
    @NonNull Dp focusedElevation,
    @NonNull Dp hoveredElevation,
    @NonNull Dp disabledElevation
)

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

Parameters
@NonNull Dp defaultElevation

the elevation used when the FilledTonalButton is enabled, and has no other Interactions.

@NonNull Dp pressedElevation

the elevation used when this FilledTonalButton is enabled and pressed.

@NonNull Dp focusedElevation

the elevation used when the FilledTonalButton is enabled and focused.

@NonNull Dp hoveredElevation

the elevation used when the FilledTonalButton is enabled and hovered.

@NonNull Dp disabledElevation

the elevation used when the FilledTonalButton is not enabled.

getButtonWithIconContentPadding

public final @NonNull PaddingValues getButtonWithIconContentPadding()

The default content padding used by Button that contains an Icon.

getContentPadding

public final @NonNull PaddingValues getContentPadding()

The default content padding used by Button, ElevatedButton, FilledTonalButton, and OutlinedButton buttons.

getElevatedShape

@Composable
public final @NonNull Shape getElevatedShape()

Default shape for an elevated button.

getFilledTonalShape

@Composable
public final @NonNull Shape getFilledTonalShape()

Default shape for a filled tonal button.

getIconSize

public final @NonNull Dp getIconSize()

The default size of the icon when used inside any button.

getIconSpacing

public final @NonNull Dp getIconSpacing()

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

getMinHeight

public final @NonNull Dp getMinHeight()

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

getMinWidth

public final @NonNull Dp getMinWidth()

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

getOutlinedButtonBorder

@Composable
public final @NonNull BorderStroke getOutlinedButtonBorder()

The default BorderStroke used by OutlinedButton.

getOutlinedShape

@Composable
public final @NonNull Shape getOutlinedShape()

Default shape for an outlined button.

getShape

@Composable
public final @NonNull Shape getShape()

Default shape for a button.

getTextButtonContentPadding

public final @NonNull PaddingValues getTextButtonContentPadding()

The default content padding used by TextButton.

getTextButtonWithIconContentPadding

public final @NonNull PaddingValues getTextButtonWithIconContentPadding()

The default content padding used by TextButton that contains an Icon.

getTextShape

@Composable
public final @NonNull Shape getTextShape()

Default shape for a text button.

outlinedButtonColors

@Composable
public final @NonNull ButtonColors outlinedButtonColors()

Creates a ButtonColors that represents the default container and content colors used in an OutlinedButton.

outlinedButtonColors

@Composable
public final @NonNull ButtonColors outlinedButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in an OutlinedButton.

Parameters
@NonNull Color containerColor

the container color of this OutlinedButton when enabled

@NonNull Color contentColor

the content color of this OutlinedButton when enabled

@NonNull Color disabledContainerColor

the container color of this OutlinedButton when not enabled

@NonNull Color disabledContentColor

the content color of this OutlinedButton when not enabled

textButtonColors

@Composable
public final @NonNull ButtonColors textButtonColors()

Creates a ButtonColors that represents the default container and content colors used in a TextButton.

textButtonColors

@Composable
public final @NonNull ButtonColors textButtonColors(
    @NonNull Color containerColor,
    @NonNull Color contentColor,
    @NonNull Color disabledContainerColor,
    @NonNull Color disabledContentColor
)

Creates a ButtonColors that represents the default container and content colors used in a TextButton.

Parameters
@NonNull Color containerColor

the container color of this TextButton when enabled

@NonNull Color contentColor

the content color of this TextButton when enabled

@NonNull Color disabledContainerColor

the container color of this TextButton when not enabled

@NonNull Color disabledContentColor

the content color of this TextButton when not enabled