<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/overlay(_:in:fillStyle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE7overlay_2in9fillStyleQrqd___qd_0_AA04FillG0VtAA05ShapeG0Rd__AA0I0Rd_0_r0_lF"
  },
  "title" : "overlay(_:in:fillStyle:)"
}
-->

# overlay(_:in:fillStyle:)

Layers a shape that you specify in front of this view.

```
nonisolated func overlay<S, T>(_ style: S, in shape: T, fillStyle: FillStyle = FillStyle()) -> some View where S : ShapeStyle, T : Shape
```

## Parameters

`style`

A [`ShapeStyle`](/documentation/SwiftUI/ShapeStyle) that SwiftUI uses to fill the shape
that you specify.

`shape`

An instance of a type that conforms to [`Shape`](/documentation/SwiftUI/Shape) that
SwiftUI draws in front of the view.

`fillStyle`

The [`FillStyle`](/documentation/SwiftUI/FillStyle) to use when drawing the shape.
The default style uses the nonzero winding number rule and
antialiasing.

## Return Value

A view with the specified shape drawn in front of it.

## Discussion

Use this modifier to layer a type that conforms to the [`Shape`](/documentation/SwiftUI/Shape)
protocol — like a [`Rectangle`](/documentation/SwiftUI/Rectangle), [`Circle`](/documentation/SwiftUI/Circle), or [`Capsule`](/documentation/SwiftUI/Capsule) — in
front of a view. Specify a [`ShapeStyle`](/documentation/SwiftUI/ShapeStyle) that’s used to fill the shape.
For example, you can overlay the outline of one rectangle in front of
another:

```
Rectangle()
    .frame(width: 200, height: 100)
    .overlay(.teal, in: Rectangle().inset(by: 10).stroke(lineWidth: 5))
```

The example above uses the [`inset(by:)`](/documentation/SwiftUI/InsettableShape/inset(by:)) method to
slightly reduce the size of the overlaid rectangle, and the
[`stroke(lineWidth:)`](/documentation/SwiftUI/Shape/stroke(lineWidth:)) method to fill only the shape’s outline.
This creates an inset border:

![A screenshot of a rectangle with a teal border that’s](images/com.apple.SwiftUI/View-overlay-7@2x.png)

This modifier is a convenience method for layering a shape over a view.
To handle the more general case of overlaying a [`View`](/documentation/SwiftUI/View) — or a stack
of views — with control over the position, use
[`overlay(alignment:content:)`](/documentation/SwiftUI/View/overlay(alignment:content:)) instead. To cover a view with a
[`ShapeStyle`](/documentation/SwiftUI/ShapeStyle), use [`overlay(_:ignoresSafeAreaEdges:)`](/documentation/SwiftUI/View/overlay(_:ignoresSafeAreaEdges:)).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)