---
title: "PolygonShape"
description: "Shape built from rounded polygon geometry."
type: "class"
lastmod: "2026-09-24"
---
## API Reference

> Source set: Common

```kotlin
public sealed class PolygonShape : Shape
```

Shape built from rounded polygon geometry.

Create instances using the [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) factory functions or predefined companion factories
like `regularPolygon` and `star`. Instances created with equal parameters compare equal to enable
caching resolved outlines across recompositions.

Shapes cache their resolved outline for their most recent layout size. Sharing a single shape
instance across composables with differing sizes is supported, but defining separate instances
per size avoids cache thrashing when repeatedly redrawing.

Outlines returned by `createOutline` are shared between callers and must not be mutated.

## Members

### Companion

> Source set: Common

```kotlin
public companion object
```

## Functions

### regularPolygon

> Source set: Common

```kotlin
public fun regularPolygon(
            @IntRange(from = 3) numVertices: Int,
            rounding: CornerRounding = CornerRounding.Unrounded,
        ): PolygonShape
```

Creates a regular polygon [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) with `numVertices` vertices, sized to the
container's smaller dimension.

#### Parameters

| | |
| --- | --- |
| numVertices | number of vertices, at least 3 |
| rounding | rounding applied to every vertex, resolved against the polygon's radius |

#### Throws: IllegalArgumentException

if `numVertices` is less than 3

### star

> Source set: Common

```kotlin
public fun star(
            @IntRange(from = 2) numPoints: Int,
            innerRadiusRatio: Float = 0.5f,
            outerRounding: CornerRounding = CornerRounding.Unrounded,
            innerRounding: CornerRounding = outerRounding,
        ): PolygonShape
```

Creates a star [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) with `numPoints` points on each of the outer and inner
radii, sized to the container's smaller dimension.

#### Parameters

| | |
| --- | --- |
| numPoints | number of points (tips) on the star, at least 2 |
| innerRadiusRatio | ratio of inner radius to outer radius, in the range (0, 1] |
| outerRounding | rounding for the outer corners, resolved against the star's outer radius |
| innerRounding | rounding for the inner corners, resolved the same way; matches `outerRounding` when not specified |

#### Throws: IllegalArgumentException

if `numPoints` is less than 2 or `innerRadiusRatio` is outside the range (0, 1]

### pill

> Source set: Common

```kotlin
public fun pill(@FloatRange(0.0, 1.0) smoothing: Float = 0f): PolygonShape
```

Creates a pill [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) with rounded ends along the shorter sides of the layout
bounds.

#### Parameters

| | |
| --- | --- |
| smoothing | the amount by which the arc is "smoothed" by extending the curve from the circular arc on each endcap to the edge between the endcaps. A value of 0 (no smoothing) indicates that the corner is rounded by only a circular arc. |

#### Throws: IllegalArgumentException

if `smoothing` is outside the range 0 to 1

### pillStar

> Source set: Common

```kotlin
public fun pillStar(
            @IntRange(from = 2) numPoints: Int,
            innerRadiusRatio: Float = 0.5f,
            vertexSpacing: Float = 0.5f,
            startLocation: Float = 0f,
            outerRounding: CornerRounding = CornerRounding.Unrounded,
            innerRounding: CornerRounding = outerRounding,
        ): PolygonShape
```

Creates a star [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) with vertices placed along a pill outline.

A `pillStar` is like a `pill` except it has inner and outer radii along its pill-shaped
outline, just as a `star` has inner and outer radii along a circular outline. This
produces an elongated star shape commonly used for badges, chips, and decorative
containers.

Because vertices curve around the semicircular ends of the pill, outer and inner vertices
have different spacing along the curved ends depending on `innerRadiusRatio`. The
`vertexSpacing` parameter controls how vertices are spaced along those curved ends:
- `vertexSpacing = 0f`: Spaces inner vertices equally along the curved ends (outer
vertices will be further apart).
- `vertexSpacing = 1f`: Spaces outer vertices equally along the curved ends (inner
vertices will be closer together).
- `vertexSpacing = 0.5f` (default): Uses the average of the inner and outer spacing so
both sets of vertices fall symmetrically along the curved ends.

#### Parameters

| | |
| --- | --- |
| numPoints | number of points (tips) on the star, at least 2 |
| innerRadiusRatio | ratio of inner radius to outer radius, in the range (0, 1] |
| vertexSpacing | how vertices on the curved ends are spaced, from 0 (inner vertices spaced evenly) to 1 (outer vertices spaced evenly); 0.5 takes the average |
| startLocation | where along the perimeter the outline starts, in the range 0 to 1 |
| outerRounding | rounding for the outer corners, resolved against the star's outer radius |
| innerRounding | rounding for the inner corners, resolved the same way; matches `outerRounding` when not specified |

#### Throws: IllegalArgumentException

if `numPoints` is less than 2, or `innerRadiusRatio` is outside (0, 1], or `vertexSpacing` or `startLocation` are outside the range 0 to 1

### circle

> Source set: Common

```kotlin
public fun circle(@IntRange(from = 3) numVertices: Int = 8): PolygonShape
```

Creates a circular [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) approximated by `numVertices` rounded vertices.

#### Parameters

| | |
| --- | --- |
| numVertices | number of vertices used to approximate the circle, at least 3 |

#### Throws: IllegalArgumentException

if `numVertices` is less than 3

### rectangle

> Source set: Common

```kotlin
public fun rectangle(rounding: CornerRounding): PolygonShape
```

Creates a rectangular [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) filling the layout bounds, with the same `rounding`
at every corner.

#### Parameters

| | |
| --- | --- |
| rounding | rounding for all 4 corners, resolved against the layout bounds |

### rectangle

> Source set: Common

```kotlin
public fun rectangle(
            topStartRounding: CornerRounding = CornerRounding.Unrounded,
            topEndRounding: CornerRounding = CornerRounding.Unrounded,
            bottomEndRounding: CornerRounding = CornerRounding.Unrounded,
            bottomStartRounding: CornerRounding = CornerRounding.Unrounded,
        ): PolygonShape
```

Creates a rectangular [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) filling the layout bounds, with a separate rounding
for each corner.

Corner roundings mirror automatically with the layout direction.

#### Parameters

| | |
| --- | --- |
| topStartRounding | rounding for the top start corner, resolved against the layout bounds |
| topEndRounding | rounding for the top end corner, resolved the same way |
| bottomEndRounding | rounding for the bottom end corner, resolved the same way |
| bottomStartRounding | rounding for the bottom start corner, resolved the same way |

### absoluteRectangle

> Source set: Common

```kotlin
public fun absoluteRectangle(
            topLeftRounding: CornerRounding = CornerRounding.Unrounded,
            topRightRounding: CornerRounding = CornerRounding.Unrounded,
            bottomRightRounding: CornerRounding = CornerRounding.Unrounded,
            bottomLeftRounding: CornerRounding = CornerRounding.Unrounded,
        ): PolygonShape
```

Creates an absolute rectangular [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) filling the layout bounds, with a separate
rounding for each corner.

Corner roundings do not swap with the layout direction.

#### Parameters

| | |
| --- | --- |
| topLeftRounding | rounding for the top left corner, resolved against the layout bounds |
| topRightRounding | rounding for the top right corner, resolved the same way |
| bottomRightRounding | rounding for the bottom right corner, resolved the same way |
| bottomLeftRounding | rounding for the bottom left corner, resolved the same way |
