---
title: "overlay(_:in:fillStyle:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/overlay(_:in:fillstyle:)"
---

# overlay(_:in:fillStyle:)

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

## Declaration

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

```

## Parameters

- `style`: A doc://com.apple.SwiftUI/documentation/SwiftUI/ShapeStyle that SwiftUI uses to fill the shape that you specify.
- `shape`: An instance of a type that conforms to doc://com.apple.SwiftUI/documentation/SwiftUI/Shape that SwiftUI draws in front of the view.
- `fillStyle`: The doc://com.apple.SwiftUI/documentation/SwiftUI/FillStyle to use when drawing the shape. The default style uses the nonzero winding number rule and antialiasing.

## Return Value

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

## Discussion

Discussion Use this modifier to layer a type that conforms to the Shape protocol — like a Rectangle, Circle, or Capsule — in front of a view. Specify a 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:) method to slightly reduce the size of the overlaid rectangle, and the stroke(lineWidth:) method to fill only the shape’s outline. This creates an inset border:

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

## See Also

### Layering views

- [Adding a background to your view](swiftui/adding-a-background-to-your-view.md)
- [ZStack](swiftui/zstack.md)
- [zIndex(_:)](swiftui/view/zindex(_:).md)
- [background(alignment:content:)](swiftui/view/background(alignment:content:).md)
- [background(_:ignoresSafeAreaEdges:)](swiftui/view/background(_:ignoressafeareaedges:).md)
- [background(ignoresSafeAreaEdges:)](swiftui/view/background(ignoressafeareaedges:).md)
- [background(_:in:fillStyle:)](swiftui/view/background(_:in:fillstyle:).md)
- [background(in:fillStyle:)](swiftui/view/background(in:fillstyle:).md)
- [overlay(alignment:content:)](swiftui/view/overlay(alignment:content:).md)
- [overlay(_:ignoresSafeAreaEdges:)](swiftui/view/overlay(_:ignoressafeareaedges:).md)
- [backgroundMaterial](swiftui/environmentvalues/backgroundmaterial.md)
- [containerBackground(_:for:)](swiftui/view/containerbackground(_:for:).md)
- [containerBackground(for:alignment:content:)](swiftui/view/containerbackground(for:alignment:content:).md)
- [ContainerBackgroundPlacement](swiftui/containerbackgroundplacement.md)
