androidx.compose.material3
ButtonDefaults
Object
Default values and helper functions for Button and the other button types.
Use it to get a default and change one part of it, for example ButtonDefaults.buttonColors(containerColor = Color.Red).
Values come in groups:
- Shapes:
shape,squareShape,pressedShape, andshapes()for Expressive buttons. - Colors:
buttonColors(),filledTonalButtonColors(),outlinedButtonColors(), … - Sizes:
MinHeight,MediumContainerHeight,IconSize,IconSpacing, … - Padding:
ContentPadding,ButtonWithIconContentPadding, … - Helpers for a height:
shapesFor(),contentPaddingFor(),iconSizeFor(),textStyleFor().
object ButtonDefaults
Properties
ContentPadding
val ContentPadding: PaddingValues
The default content padding used by Button, ElevatedButton, FilledTonalButton, OutlinedButton, and TextButton buttons. - See ButtonWithIconContentPadding for content padding used by Button that contains Icon.
ButtonWithIconContentPadding
val ButtonWithIconContentPadding: PaddingValues
The default content padding used by Button that contains an Icon.
SmallContentPaddingSince 1.10
val SmallContentPadding: PaddingValues
The default content padding used for small Button
ExtraSmallContentPaddingSince 1.10
val ExtraSmallContentPadding: PaddingValues
Default content padding for an extra small button.
MediumContentPaddingSince 1.10
val MediumContentPadding: PaddingValues
Default content padding for a medium button.
LargeContentPaddingSince 1.10
val LargeContentPadding: PaddingValues
Default content padding for a large button.
ExtraLargeContentPaddingSince 1.10
val ExtraLargeContentPadding: PaddingValues
Default content padding for an extra large button.
TextButtonContentPadding
val TextButtonContentPadding: PaddingValues
The default content padding used by TextButton. - See TextButtonWithIconContentPadding for content padding used by TextButton that contains Icon.
TextButtonWithIconContentPadding
val TextButtonWithIconContentPadding: PaddingValues
The default content padding used by TextButton that contains an Icon.
MinWidth
val MinWidth: Dp
The default min width applied for small buttons. Note that you can override it by applying Modifier.widthIn directly on the button composable.
MinHeight
val MinHeight: Dp
The default min height applied for small buttons. Note that you can override it by applying Modifier.heightIn directly on the button composable.
ExtraSmallContainerHeightSince 1.10
val ExtraSmallContainerHeight: Dp
The default height for a extra small button container.
MediumContainerHeightSince 1.10
val MediumContainerHeight: Dp
The default height for a medium button container.
LargeContainerHeightSince 1.10
val LargeContainerHeight: Dp
The default height for a large button container.
ExtraLargeContainerHeightSince 1.10
val ExtraLargeContainerHeight: Dp
The default height for a extra large button container.
IconSize
val IconSize: Dp
The default size of the icon when used inside a small button.
ExtraSmallIconSizeSince 1.10
val ExtraSmallIconSize: Dp
The default size of the icon used inside an extra small button.
SmallIconSizeSince 1.10
val SmallIconSize: Dp
The expressive size of the icon used inside a small button.
MediumIconSizeSince 1.10
val MediumIconSize: Dp
The default size of the icon used inside a medium button.
LargeIconSizeSince 1.10
val LargeIconSize: Dp
The default size of the icon used inside a large button.
ExtraLargeIconSizeSince 1.10
val ExtraLargeIconSize: Dp
The default size of the icon used inside an extra large button.
IconSpacing
val IconSpacing: Dp
The default size of the spacing between an icon and a text when they used inside a small button.
ExtraSmallIconSpacingSince 1.10
val ExtraSmallIconSpacing: Dp
The default spacing between an icon and a text when they used inside any extra small button.
MediumIconSpacingSince 1.10
val MediumIconSpacing: Dp
The default spacing between an icon and a text when they're inside any medium button.
LargeIconSpacingSince 1.10
val LargeIconSpacing: Dp
The default spacing between an icon and a text when they're inside any large button.
ExtraLargeIconSpacingSince 1.10
val ExtraLargeIconSpacing: Dp
The default spacing between an icon and a text when they used inside any extra large button.
squareShapeSince 1.10
@Composable val squareShape: Shape
The theme's medium shape (12 dp corners by default).
pressedShapeSince 1.10
@Composable val pressedShape: Shape
The theme's small shape (8 dp corners by default). Used while an Expressive button is pressed.
extraSmallPressedShapeSince 1.10
@Composable val extraSmallPressedShape: Shape
Pressed shape for extra small buttons.
mediumPressedShapeSince 1.10
@Composable val mediumPressedShape: Shape
Pressed shape for medium buttons.
largePressedShapeSince 1.10
@Composable val largePressedShape: Shape
Pressed shape for large buttons.
extraLargePressedShapeSince 1.10
@Composable val extraLargePressedShape: Shape
Pressed shape for extra large buttons.
shape
@Composable val shape: Shape
Fully round. The default for Button.
elevatedShape
@Composable val elevatedShape: Shape
Default shape for an elevated button.
filledTonalShape
@Composable val filledTonalShape: Shape
Default shape for a filled tonal button.
outlinedShape
@Composable val outlinedShape: Shape
Default shape for an outlined button.
textShape
@Composable val textShape: Shape
Default shape for a text button.
outlinedButtonBorder
@Composable val outlinedButtonBorder: BorderStroke
The default BorderStroke used by OutlinedButton.
Functions
shapesSince 1.10
@Composable
fun shapes(): ButtonShapes
Makes a ButtonShapes. With no arguments: round at rest, pressedShape while pressed.
@Composable
fun shapes(
shape: Shape? = null,
pressedShape: Shape? = null,
): ButtonShapes
Makes a ButtonShapes. With no arguments: round at rest, pressedShape while pressed.
buttonColors
@Composable
fun buttonColors(): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in a Button.
@Composable
fun buttonColors(
containerColor: Color = Color.Unspecified,
contentColor: Color = Color.Unspecified,
disabledContainerColor: Color = Color.Unspecified,
disabledContentColor: Color = Color.Unspecified,
): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in a Button.
elevatedButtonColors
@Composable
fun elevatedButtonColors(): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in an ElevatedButton.
@Composable
fun elevatedButtonColors(
containerColor: Color = Color.Unspecified,
contentColor: Color = Color.Unspecified,
disabledContainerColor: Color = Color.Unspecified,
disabledContentColor: Color = Color.Unspecified,
): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in an ElevatedButton.
filledTonalButtonColors
@Composable
fun filledTonalButtonColors(): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in an FilledTonalButton.
@Composable
fun filledTonalButtonColors(
containerColor: Color = Color.Unspecified,
contentColor: Color = Color.Unspecified,
disabledContainerColor: Color = Color.Unspecified,
disabledContentColor: Color = Color.Unspecified,
): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in an FilledTonalButton.
outlinedButtonColors
@Composable
fun outlinedButtonColors(): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in an OutlinedButton.
@Composable
fun outlinedButtonColors(
containerColor: Color = Color.Unspecified,
contentColor: Color = Color.Unspecified,
disabledContainerColor: Color = Color.Unspecified,
disabledContentColor: Color = Color.Unspecified,
): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in an OutlinedButton.
textButtonColors
@Composable
fun textButtonColors(): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in a TextButton.
@Composable
fun textButtonColors(
containerColor: Color = Color.Unspecified,
contentColor: Color = Color.Unspecified,
disabledContainerColor: Color = Color.Unspecified,
disabledContentColor: Color = Color.Unspecified,
): ButtonColors
Creates a ButtonColors that represents the default container and content colors used in a TextButton.
buttonElevation
@Composable
fun buttonElevation(
defaultElevation: Dp = FilledButtonTokens.ContainerElevation,
pressedElevation: Dp = FilledButtonTokens.PressedContainerElevation,
focusedElevation: Dp = FilledButtonTokens.FocusedContainerElevation,
hoveredElevation: Dp = FilledButtonTokens.HoveredContainerElevation,
disabledElevation: Dp = FilledButtonTokens.DisabledContainerElevation,
): ButtonElevation
Creates a ButtonElevation that will animate between the provided values according to the Material specification for a Button.
elevatedButtonElevation
@Composable
fun elevatedButtonElevation(
defaultElevation: Dp = ElevatedButtonTokens.ContainerElevation,
pressedElevation: Dp = ElevatedButtonTokens.PressedContainerElevation,
focusedElevation: Dp = ElevatedButtonTokens.FocusedContainerElevation,
hoveredElevation: Dp = ElevatedButtonTokens.HoveredContainerElevation,
disabledElevation: Dp = ElevatedButtonTokens.DisabledContainerElevation,
): ButtonElevation
Creates a ButtonElevation that will animate between the provided values according to the Material specification for a ElevatedButton.
filledTonalButtonElevation
@Composable
fun filledTonalButtonElevation(
defaultElevation: Dp = FilledTonalButtonTokens.ContainerElevation,
pressedElevation: Dp = FilledTonalButtonTokens.PressedContainerElevation,
focusedElevation: Dp = FilledTonalButtonTokens.FocusContainerElevation,
hoveredElevation: Dp = FilledTonalButtonTokens.HoverContainerElevation,
disabledElevation: Dp = 0.dp,
): ButtonElevation
Creates a ButtonElevation that will animate between the provided values according to the Material specification for a FilledTonalButton.
@Composable
fun outlinedButtonBorder(
enabled: Boolean = true,
): BorderStroke
The default BorderStroke used by OutlinedButton.
shapesForSince 1.10
@Composable
fun shapesFor(buttonHeight: Dp): ButtonShapes
Picks a ButtonShapes that fits a button of the given height.
contentPaddingForSince 1.10Experimental
fun contentPaddingFor(
buttonHeight: Dp,
hasStartIcon: Boolean = false,
hasEndIcon: Boolean = false,
): PaddingValues
Recommended PaddingValues for a provided button height.
iconSizeForSince 1.10
fun iconSizeFor(buttonHeight: Dp): Dp
Recommended Icon size for a provided button height.
iconSpacingForSince 1.10
fun iconSpacingFor(buttonHeight: Dp): Dp
Recommended spacing after an Icon for a provided button height.
textStyleForSince 1.10
@Composable
fun textStyleFor(buttonHeight: Dp): TextStyle
Recommended TextStyle for a Text provided a button height.