Defines the radius and smoothness of rounding at a polygon vertex.

  • Unrounded (radius = 0) keeps a sharp corner.

  • smoothing = 0f rounds the corner with a circular arc.

  • smoothing > 0f extends symmetric cubic Bézier flanking curves from the circular arc toward the adjacent edges (1f maximizes the flanking curves).

Create instances with CornerRounding.dp, CornerRounding.fraction, or Unrounded.

Summary

Public companion functions

CornerRounding
dp(radius: Dp, smoothing: @FloatRange(from = 0.0, to = 1.0) Float)

Creates a CornerRounding with a radius in Dp.

Cmn
CornerRounding
fraction(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float,
    smoothing: @FloatRange(from = 0.0, to = 1.0) Float
)

Creates a CornerRounding with a radius as a fraction of the polygon's size.

Cmn

Public companion properties

CornerRounding

Sharp corner with a rounding radius of zero.

Cmn

Public functions

open operator Boolean
equals(other: Any?)
Cmn
open Int
Cmn
open String
Cmn

Public companion functions

dp

fun dp(radius: Dp, smoothing: @FloatRange(from = 0.0, to = 1.0) Float = 0.0f): CornerRounding

Creates a CornerRounding with a radius in Dp.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CornerRounding
import androidx.compose.foundation.shape.PolygonShape
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

// A regular hexagon sized to the container's smaller dimension with an exact 16.dp corner
// rounding resolved against the current density.
val hexagon = remember {
    PolygonShape {
        polygon(
            numVertices = 6,
            radius = size.minDimension / 2f,
            center = Offset(size.width / 2f, size.height / 2f),
            rounding = CornerRounding.dp(radius = 16.dp),
        )
    }
}
Box(Modifier.size(96.dp).clip(hexagon).background(Color(0xFF3F51B5)))
Parameters
radius: Dp

corner rounding radius, at least 0.dp

smoothing: @FloatRange(from = 0.0, to = 1.0) Float = 0.0f

transition smoothness from the circular arc to adjacent edges, in 0f..1f

Throws
IllegalArgumentException

if radius is negative/unspecified or smoothing is outside 0f..1f

fraction

fun fraction(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float,
    smoothing: @FloatRange(from = 0.0, to = 1.0) Float = 0.0f
): CornerRounding

Creates a CornerRounding with a radius as a fraction of the polygon's size.

For polygons defined with a radius (such as PolygonShape.regularPolygon, PolygonShape.star, and PolygonShapeScope.polygon with radius), the corner radius is [fraction] * radius. For polygons defined with custom vertices (PolygonShapeGeometry), which do not have a radius, the corner radius is a fraction of the polygon's smaller dimension (min(width, height)).

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CornerRounding
import androidx.compose.foundation.shape.PolygonShape
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

// A pentagon whose corners round to a 0.2f fraction of its generating radius, so the rounding
// scales proportionally with the shape at any size.
val pentagon = remember {
    PolygonShape.regularPolygon(numVertices = 5, rounding = CornerRounding.fraction(0.2f))
}
Box(Modifier.size(96.dp).clip(pentagon).background(Color(0xFF009688)))
Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float

rounding radius as a fraction of the polygon's size, in 0f..1f

smoothing: @FloatRange(from = 0.0, to = 1.0) Float = 0.0f

transition smoothness from the circular arc to adjacent edges, in 0f..1f

Throws
IllegalArgumentException

if fraction or smoothing is outside 0f..1f

Public companion properties

Unrounded

val Unrounded: CornerRounding

Sharp corner with a rounding radius of zero.

Public functions

equals

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

hashCode

open fun hashCode(): Int

toString

open fun toString(): String