Rectangle and RoundedRectangle are sharp- and rounded-corner rectangles; Capsule is a rounded rectangle with maximum corner radius. Circle and Ellipse are radial primitives. Path builds an arbitrary vector shape from drawing commands.
Every shape supports .fill(style) to paint its interior and .stroke(style) to draw its outline. Shapes also work as .clipShape(), .background(), or .overlay() arguments for other components.
Rectangle
A rectangle shape that fills its frame.(style: Style) => Shape
Fills the rectangle interior with a color, gradient, or other style.
(style: Style | StrokeOptions) => Shape
Draws the rectangle outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.For rounded corners, use RoundedRectangle or the
.cornerRadius() modifier.RoundedRectangle
A rectangle with rounded corners.object
Configuration options for the rounded rectangle.
(style: Style) => Shape
Fills the rounded rectangle interior with a color, gradient, or other style.
(style: Style | StrokeOptions) => Shape
Draws the rounded rectangle outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.For fully rounded ends (pill shape), use Capsule instead of computing the corner radius manually. RoundedRectangle can also be used with
.clipShape() and .contentShape() modifiers.Circle
A circle shape centered in its frame.(style: Style) => Shape
Fills the circle interior with a color, gradient, or other style.
(style: Style | StrokeOptions) => Shape
Draws the circle outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.Ellipse
An ellipse shape that fills its frame.(style: Style) => Shape
Fills the ellipse interior with a color, gradient, or other style.
(style: Style | StrokeOptions) => Shape
Draws the ellipse outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.When the frame is square, Ellipse renders identically to Circle.
Capsule
A capsule shape — a rounded rectangle with maximum corner radius.(style: Style) => Shape
Fills the capsule interior with a color, gradient, or other style.
(style: Style | StrokeOptions) => Shape
Draws the capsule outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.When the frame is square, Capsule renders as a circle. Use Circle directly if a circle is always intended. For a rounded rectangle with a specific corner radius, use RoundedRectangle instead.
Path
Creates a custom vector shape from path drawing commands.(path: PathBuilder) => void
required
A function that receives a PathBuilder and uses its drawing commands to construct the shape.
path parameter provides the following drawing commands:
(x: number, y: number) => void
Begins a new subpath at the given point.
(x: number, y: number) => void
Adds a straight line from the current point to the given point.
(x: number, y: number, controlX: number, controlY: number) => void
Adds a quadratic Bezier curve to the given point with one control point.
(x: number, y: number, control1X: number, control1Y: number, control2X: number, control2Y: number) => void
Adds a cubic Bezier curve to the given point with two control points.
(props: { centerX: number; centerY: number; radius: number; startAngle: number; endAngle: number; clockwise?: boolean }) => void
Adds an arc. Angles are specified in degrees.
(x: number, y: number, width: number, height: number) => void
Adds a rectangle subpath.
(props: { x: number; y: number; width: number; height: number; cornerWidth: number; cornerHeight: number }) => void
Adds a rounded rectangle subpath.
(x: number, y: number, width: number, height: number) => void
Adds an ellipse subpath inscribed in the given rectangle.
(points: [number, number][]) => void
Adds a polyline from an array of
[x, y] coordinate pairs.() => void
Closes the current subpath by drawing a line back to the starting point.
(style: Style) => Shape
Fills the path interior with a color, gradient, or other style.
(style: Style | StrokeOptions) => Shape
Draws the path outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.Coordinates are relative to the Path’s own coordinate space — use
.frame() to set the overall size. Path returns a Shape, so it can be used anywhere shapes are accepted, including .clipShape(), .background(), and .overlay(). Multiple subpaths can be created by calling move() multiple times within a single builder.See also
- LinearGradient — gradient fills for shapes
- Color — solid color fills and strokes
- Image — bitmap content to clip with shapes
- ZStack — layer shapes behind or in front of content