Shapes
Most components have a shape parameter. It always takes a Shape. This page shows where a Shape can come from, and why there are so many types.
Example
Pass any of these to shape:
shape = RoundedCornerShape(8.dp) // make your own
shape = MaterialTheme.shapes.medium // from the theme
shape = ButtonDefaults.squareShape // the component's own preset
shape = CircleShape // fully round
shape = MaterialShapes.Cookie9Sided.toShape() // Expressive
They all work because they are all a Shape.
The types
Shape interface: "something that has an outline"
├── RectangleShape a value: square corners
├── GenericShape draw any path yourself
└── CornerBasedShape a shape defined by four corners
├── RoundedCornerShape round corners ← most used
├── CutCornerShape cut (diagonal) corners
├── AbsoluteRoundedCornerShape same, ignores right-to-left layout
└── AbsoluteCutCornerShape
Shapeis what parameters ask for.CornerBasedShapeis aShapemade of four corners. You rarely use it by name, but the theme does.RoundedCornerShapeandCutCornerShapeare the ones you create.CircleShapeis a ready-madeRoundedCornerShape(50): 50 % corners make a pill or a circle.
Corners: CornerSize
Each corner of a CornerBasedShape has a CornerSize. You usually don't create one yourself, because RoundedCornerShape has shortcuts:
RoundedCornerShape(8.dp) // all corners 8 dp
RoundedCornerShape(percent = 50) // all corners 50 % of the shorter side
RoundedCornerShape(topStart = 16.dp) // only one corner
RoundedCornerShape(CornerSize(8.dp)) // the long way, same as the first line
start and end flip in right-to-left languages. Use the Absolute… shapes if you need left and right instead.
Theme shapes: Shapes and ShapeDefaults
The theme holds a set of shapes from small to large. Read them with MaterialTheme.shapes:
MaterialTheme.shapes.extraSmall // 4 dp corners
MaterialTheme.shapes.small // 8 dp
MaterialTheme.shapes.medium // 12 dp
MaterialTheme.shapes.large // 16 dp
MaterialTheme.shapes.extraLarge // 28 dp
Expressive adds largeIncreased (20 dp), extraLargeIncreased (32 dp) and extraExtraLarge (48 dp).
Shapesis the class that holds these. Each one is aCornerBasedShape.ShapeDefaultshas the default values.Shapes()uses them unless you pass your own.
To change the shapes for the whole app, pass a Shapes to the theme:
MaterialTheme(
shapes = Shapes(small = RoundedCornerShape(4.dp)),
) { /* app */ }
Components that use theme shapes change with it.
Component presets: XxxDefaults
Each component has a …Defaults object with its own shapes. For buttons:
ButtonDefaults.shape: fully round. This is the default.ButtonDefaults.squareShape: the theme'smediumshape.ButtonDefaults.pressedShape: the theme'ssmallshape.
These are plain Shape values. Pass them to shape like any other.
Expressive: shapes that change on press
Expressive buttons can morph when pressed. That needs two shapes, so the parameter is shapes (plural) and takes a ButtonShapes:
Button(onClick = {}, shapes = ButtonDefaults.shapes()) { Text("Press me") }
ButtonShapesholdsshapeandpressedShape.ButtonDefaults.shapesmakes one. With no arguments it uses the theme defaults. PassshapeorpressedShapeto change one of them.ButtonDefaults.shapesForpicks shapes that match a button height. Use it with the Expressive sizes.
shape and shapes are two different Button overloads. Use one or the other.
Expressive: MaterialShapes
MaterialShapes has 35 decorative shapes: Cookie9Sided, Heart, Clover4Leaf, Sunny, and more. They are not Shape values. They are RoundedPolygons, which can also be animated into each other.
Turn one into a Shape with toShape:
shape = MaterialShapes.Cookie9Sided.toShape()

Button(
onClick = {},
shape = MaterialShapes.Cookie9Sided.toShape(),
contentPadding = PaddingValues(0.dp),
modifier = Modifier.size(72.dp),
) {
Icon(Icons.Filled.Favorite, contentDescription = "Like")
}
Examples on a button

Button(onClick = {}) {
Text("Default")
}

Button(onClick = {}, shape = ButtonDefaults.squareShape) {
Text("Square")
}

Button(onClick = {}, shape = MaterialTheme.shapes.small) {
Text("Theme small")
}

Button(onClick = {}, shape = RoundedCornerShape(percent = 25)) {
Text("25 %")
}

Button(
onClick = {},
shape = RoundedCornerShape(topStart = 20.dp, bottomEnd = 20.dp),
) {
Text("Leaf")
}

Button(onClick = {}, shape = CutCornerShape(8.dp)) {
Text("Cut")
}

Button(
onClick = {},
shapes = ButtonDefaults.shapes(
shape = ButtonDefaults.squareShape,
pressedShape = RoundedCornerShape(4.dp),
),
) {
Text("Square, tighter when pressed")
}
Summary
| You want | Write |
|---|---|
| Fixed corners | RoundedCornerShape(8.dp) |
| Follow the theme | MaterialTheme.shapes.medium |
| Pill or circle | CircleShape |
| Cut corners | CutCornerShape(8.dp) |
| Square corners | RectangleShape |
| Different shape when pressed | shapes = ButtonDefaults.shapes(...) |
| A decorative shape | MaterialShapes.Heart.toShape() |
| Change shapes app-wide | MaterialTheme(shapes = Shapes(...)) |