How it works
FillShapeStyle is the shape style behind the fill shortcut: a context-dependent neutral fill that adapts to its surroundings, foreground material, and the current light or dark appearance. Reach for it when you need a filled background or shape that reads as part of the system's surface hierarchy rather than a fixed color you have to hand-tune. Because it resolves at render time against the environment, the same fill stays legible whether it sits on a card, inside a sheet, or over a vibrant material.
Apply the style with
.fillFillShapeStyleis rarely named directly; you reach it through theShapeStylestatic memberfill. Passing.fillto a shape'sfill(_:)modifier paints the shape with the adaptive neutral fill, as inRoundedRectangle(cornerRadius: 12).fill(.fill).Fill a shape via
fill(_:)Any
Shapeaccepts aShapeStylethroughfill(_:), andFillShapeStyleconforms toShapeStyle, so it slots in wherever a color or gradient would. Here it gives theRoundedRectanglea system-appropriate body, thenframe(width:height:)and anoverlay(Text("Filled"))sit on top unchanged.Step down emphasis with hierarchical levels
FillShapeStyleexposes the same hierarchical accessors as other adaptive styles, so.secondary,.tertiary,.quaternary, and.quinaryreturn progressively fainter variants of the same fill.Circle().fill(.fill.tertiary)requests the third level, producing a lighter wash than the plain.fillused above it.Let the environment resolve the color
FillShapeStylehas no color parameter of its own; it computes its appearance from the surrounding context and color scheme when the view is drawn. That is why both.filland.fill.tertiaryshift automatically between light and dark mode without any conditional code inFillShapeStyleDemo.
Circle().fill(.fill.tertiary) to .fill.quaternary and place it on differing backgrounds to watch FillShapeStyle lighten and re-tint itself per level and appearance.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct FillShapeStyleDemo: View {
var body: some View {
VStack(spacing: 16) {
RoundedRectangle(cornerRadius: 12)
.fill(.fill)
.frame(width: 160, height: 80)
.overlay(Text("Filled"))
Circle()
.fill(.fill.tertiary)
.frame(width: 60, height: 60)
}
.padding()
}
}