androidx.compose.material3
ButtonShapesSince 1.10
Class
Two shapes for one button: shape at rest and pressedShape while pressed. The button animates between them.
Pass it to the shapes parameter of Button and the other button types.
Button(
onClick = {},
shapes = ButtonDefaults.shapes(pressedShape = RoundedCornerShape(4.dp)),
) { Text("Press me") }

Button(
onClick = {},
shapes = ButtonDefaults.shapes(
shape = ButtonDefaults.squareShape,
pressedShape = RoundedCornerShape(4.dp),
),
) {
Text("Square, tighter when pressed")
}
class ButtonShapes(
shape: Shape,
pressedShape: Shape,
)
How to get one
Use ButtonDefaults.shapes. With no arguments it gives the theme defaults.
Create it
ButtonShapes(shape, pressedShape)constructor
Ready-made values and functions that return it
Used by
Parameters that take a ButtonShapes.
Button(shapes)ElevatedButton(shapes)FilledTonalButton(shapes)OutlinedButton(shapes)TextButton(shapes)
Properties
shape
val shape: Shape
The shape when the button is not pressed.
pressedShape
val pressedShape: Shape
The shape while the button is pressed.
Functions
copy
fun copy(
shape: Shape? = this.shape,
pressedShape: Shape? = this.pressedShape,
): ButtonShapes
Returns a copy with one or both shapes replaced.