The Shape
type defines a visual clipping or background shape used in view modifiers such as clipShape
, background
, or border
. It mirrors SwiftUI's Shape
protocol and supports standard system shapes and custom rounded rectangle configurations.
A Shape
can be:
'circle'
, 'rect'
, etc.)These shapes are aligned within the frame of the containing view and are commonly used for clipping, masking, or background styling.
'rect'
A standard rectangle. Can be customized with corner radius via the object form.
'circle'
A perfect circle centered within the view’s frame. Its radius is half the length of the frame's shortest side.
'capsule'
An elongated oval shape that spans the full width or height of the frame. Equivalent to a rounded rectangle with a corner radius equal to half of the shorter side.
'ellipse'
An ellipse that fills the frame.
'buttonBorder'
A system-resolved shape for button borders. It automatically adapts based on platform and system context.
'containerRelative'
A container-adaptive shape. If a container shape is defined in the view hierarchy, this resolves to a version of that shape. Otherwise, it defaults to a rectangle.
To customize corner appearance on a rectangle, use one of the following object forms:
cornerRadius
: Radius applied uniformly to all corners.style
(optional): Corner style, such as 'circular'
or 'continuous'
.RoundedCornerStyle
Optional style that affects the curvature:
"circular"
: Traditional iOS-style round corners."continuous"
(default): Smooth and adaptive curves, typically used in modern UI designs.Shape Type | Description |
---|---|
'rect' |
Plain rectangle |
'circle' |
Circle inside the smallest side of the frame |
'capsule' |
Rounded shape spanning width or height |
'ellipse' |
Ellipse stretched to frame |
'buttonBorder' |
Adaptive button outline shape |
'containerRelative' |
Depends on parent container shape; falls back to rectangle |
custom rect |
Rectangles with specific corner radius or per-corner configurations |