# RoundedCornerShape

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/shape/RoundedCornerShape.kt+class:androidx.compose.foundation.shape.RoundedCornerShape) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0) Common/All
- Cmn

  ```
  class RoundedCornerShape : CornerBasedShape
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.compose.foundation.shape.CornerBasedShape](https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape) ||
|   | ↳ | [androidx.compose.foundation.shape.RoundedCornerShape](https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape) |

*** ** * ** ***

A shape describing the rectangle with rounded corners.

This shape will automatically mirror the corner sizes in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection#Rtl`, use `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/AbsoluteRoundedCornerShape` for the layout direction unaware version of this shape.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#RoundedCornerShape(androidx.compose.foundation.shape.CornerSize,androidx.compose.foundation.shape.CornerSize,androidx.compose.foundation.shape.CornerSize,androidx.compose.foundation.shape.CornerSize)( topStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize, topEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize, bottomEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize, bottomStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize )` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#copy(androidx.compose.foundation.shape.CornerSize,androidx.compose.foundation.shape.CornerSize,androidx.compose.foundation.shape.CornerSize,androidx.compose.foundation.shape.CornerSize)( topStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize, topEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize, bottomEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize, bottomStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize )` Creates a copy of this Shape with a new corner sizes. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#createOutline(androidx.compose.ui.geometry.Size,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.unit.LayoutDirection)( size: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size, topStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, topEnd: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottomEnd: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, bottomStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, layoutDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection )` Creates `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` of this shape for the given `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#createOutline(androidx.compose.ui.geometry.Size,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.unit.LayoutDirection)`. | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#hashCode()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#lerp(kotlin.Any,kotlin.Float)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, t: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Default implementation. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#toString()()` | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape.https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape#(androidx.compose.foundation.shape.RoundedCornerShape).toPolygonShape()()` Converts a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape` to a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape`. | Cmn |

### Inherited functions

From [androidx.compose.foundation.shape.CornerBasedShape](https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape) `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#copy(androidx.compose.foundation.shape.CornerSize)(all: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize)`

Creates a copy of this Shape with a new corner size.
Cmn `final https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#createOutline(androidx.compose.ui.geometry.Size,androidx.compose.ui.unit.LayoutDirection,androidx.compose.ui.unit.Density)(
size: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size,
layoutDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection,
density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density
)`

Creates `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` of this shape for the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Shape#createOutline(androidx.compose.ui.geometry.Size,androidx.compose.ui.unit.LayoutDirection,androidx.compose.ui.unit.Density)`.
Cmn

### Inherited properties

From [androidx.compose.foundation.shape.CornerBasedShape](https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape) `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#bottomEnd()`

a size of the bottom end corner
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#bottomStart()`

a size of the bottom start corner
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#topEnd()`

a size of the top end corner
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#topStart()`

a size of the top start corner
Cmn

## Public constructors

### RoundedCornerShape

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
RoundedCornerShape(
    topStart: CornerSize,
    topEnd: CornerSize,
    bottomEnd: CornerSize,
    bottomStart: CornerSize
)
```

| Parameters |
|---|---|
| `topStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` | a size of the top start corner |
| `topEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` | a size of the top end corner |
| `bottomEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` | a size of the bottom end corner |
| `bottomStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize` | a size of the bottom start corner |

## Public functions

### copy

Cmn

```
open fun copy(
    topStart: CornerSize = this.topStart,
    topEnd: CornerSize = this.topEnd,
    bottomEnd: CornerSize = this.bottomEnd,
    bottomStart: CornerSize = this.bottomStart
): RoundedCornerShape
```

Creates a copy of this Shape with a new corner sizes.

| Parameters |
|---|---|
| `topStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize = this.topStart` | a size of the top start corner |
| `topEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize = this.topEnd` | a size of the top end corner |
| `bottomEnd: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize = this.bottomEnd` | a size of the bottom end corner |
| `bottomStart: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerSize = this.bottomStart` | a size of the bottom start corner |

### createOutline

Cmn

```
open fun createOutline(
    size: Size,
    topStart: Float,
    topEnd: Float,
    bottomEnd: Float,
    bottomStart: Float,
    layoutDirection: LayoutDirection
): Outline
```

Creates `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Outline` of this shape for the given `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerBasedShape#createOutline(androidx.compose.ui.geometry.Size,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,androidx.compose.ui.unit.LayoutDirection)`.

| Parameters |
|---|---|
| `size: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | the size of the shape boundary. |
| `topStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the resolved size of the top start corner |
| `topEnd: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the resolved size for the top end corner |
| `bottomEnd: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the resolved size for the bottom end corner |
| `bottomStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the resolved size for the bottom start corner |
| `layoutDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection` | the current layout direction. |

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### lerp

Cmn

```
open fun lerp(other: Any?, t: Float): Any?
```

Default implementation. Returns null. Override this to get interpolatable benefits.

### toString

Cmn

```
open fun toString(): String
```

## Extension functions

### RoundedCornerShape.toPolygonShape

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/shape/PolygonShape.kt+function:toPolygonShape)

```
fun RoundedCornerShape.toPolygonShape(): PolygonShape
```

Converts a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape` to a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape`.

Note: Approximates `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/RoundedCornerShape` using cubic Bézier curves and is not pixel-identical.

```kotlin
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.MorphPolygonShape
import androidx.compose.foundation.shape.PolygonShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.toPolygonShape
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

// Converting a corner-based shape to a PolygonShape lets it morph with any other polygon
// shape; here a rounded rectangle relaxes into a circle.
var expanded by remember { mutableStateOf(false) }
val progress by animateFloatAsState(if (expanded) 1f else 0f)
val shape = remember {
    MorphPolygonShape(
        start = RoundedCornerShape(12.dp).toPolygonShape(),
        end = PolygonShape.circle(),
        progress = { progress },
    )
}
Box(
    Modifier.size(96.dp).clip(shape).background(Color(0xFF03A9F4)).clickable {
        expanded = !expanded
    }
)
```