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.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.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.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.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.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.A function that receives a PathBuilder and uses its drawing commands to construct the shape.
path parameter provides the following drawing commands:
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.
(props: { x: number; y: number; width: number; height: number; cornerWidth: number; cornerHeight: number }) => void
Adds a rounded rectangle subpath.
Adds an ellipse subpath inscribed in the given rectangle.
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