---
title: "roundedRect"
description: "A rectangle with rounded corners."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "shape"
categorySlug: "shape"
categoryTitle: "Shapes"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/shape.ts#L72"
---

# roundedRect

A rectangle with rounded corners.

```ts
roundedRect(x: Val, y: Val, width: Val, height: Val, rounding: Val): Expr
```

Import `shape` from `shaders/std` and use `shape.roundedRect`.

`width` and `height` are half-extents (the distance from the centre to each side), in uv. `rounding` is the corner radius. Pass 0 for a sharp rectangle.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `x` | `Val` |  |
| `y` | `Val` |  |
| `width` | `Val` |  |
| `height` | `Val` |  |
| `rounding` | `Val` |  |

## Example

```ts
shape: {distance: ({x, y}, u) => roundedRect(x, y, u('width'), u('height'), u('rounding')), …}
```

> **Tip.** A `width` of 0.5 spans the full canvas height, not half of it.

## See also

- [`parallelogram`](/docs/primitives/shape/parallelogram) — A parallelogram: a rectangle with its top edge slid sideways.
- [`trapezoid`](/docs/primitives/shape/trapezoid) — A trapezoid: a four-sided shape with a flat top and bottom of different widths.
- [`cross`](/docs/primitives/shape/cross) — A plus-shaped cross with four equal arms.

## Used by

[RoundedRect](/docs/components/roundedrect), [Waveform](/docs/components/waveform)