Guides

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

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).

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:

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") }

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()
An Expressive shape from MaterialShapesExpressive theme
An Expressive shape from MaterialShapes
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

Default shape (fully rounded)
Default shape (fully rounded)
Button(onClick = {}) {
    Text("Default")
}
The Material square shape
The Material square shape
Button(onClick = {}, shape = ButtonDefaults.squareShape) {
    Text("Square")
}
A shape from the theme
A shape from the theme
Button(onClick = {}, shape = MaterialTheme.shapes.small) {
    Text("Theme small")
}
Corners as a percent of the height
Corners as a percent of the height
Button(onClick = {}, shape = RoundedCornerShape(percent = 25)) {
    Text("25 %")
}
Different corners
Different corners
Button(
    onClick = {},
    shape = RoundedCornerShape(topStart = 20.dp, bottomEnd = 20.dp),
) {
    Text("Leaf")
}
Cut corners
Cut corners
Button(onClick = {}, shape = CutCornerShape(8.dp)) {
    Text("Cut")
}
Your own resting and pressed shapesExpressive theme
Your own resting and pressed shapes
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(...))