<!--
{
  "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/contentShape(_:_:eoFill:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12contentShape__6eoFillQrAA07ContentE5KindsV_qd__SbtAA0E0Rd__lF"
  },
  "title" : "contentShape(_:_:eoFill:)"
}
-->

# contentShape(_:_:eoFill:)

Sets the content shape for this view.

```
nonisolated func contentShape<S>(_ kind: ContentShapeKinds, _ shape: S, eoFill: Bool = false) -> some View where S : Shape
```

## Parameters

`kind`

The kinds to apply to this content shape.

`shape`

The shape to use.

`eoFill`

A Boolean that indicates whether the shape is interpreted
with the even-odd winding number rule.

## Return Value

A view that uses the given shape for the specified kind.

## Discussion

The content shape has a variety of uses. You can control the kind of the
content shape by specifying one in `kind`. The following example sets
the focus ring shape of the view, without affecting its shape for
hit-testing:

```
MyFocusableView()
    .contentShape(.focusEffect, Circle())
```

You can apply multiple kinds of content shapes to the same view. For
example, apply a [`interaction`](/documentation/SwiftUI/ContentShapeKinds/interaction) shape and
[`focusEffect`](/documentation/SwiftUI/ContentShapeKinds/focusEffect) shape together to set both the
hit-testing shape and focus ring shape on a view.

## Context Menu & Drag Previews

You can control the preview shown by the system for context menus or
drags using the relevant content shape kind, like
[`dragPreview`](/documentation/SwiftUI/ContentShapeKinds/dragPreview) and
[`contextMenuPreview`](/documentation/SwiftUI/ContentShapeKinds/contextMenuPreview).

The following example creates a [`VStack`](/documentation/SwiftUI/VStack) of an [`Image`](/documentation/SwiftUI/Image) and [`Text`](/documentation/SwiftUI/Text)
that has a context menu with a custom content shape:

```
VStack {
    Image("turtlerock")
        .contentShape(.contextMenuPreview,
                      RoundedRectangle(cornerRadius: 10))
    Text("Turtle Rock")
}
.contextMenu {
    Button {
        // Add this item to a list of favorites.
    } label: {
        Label("Add to Favorites", systemImage: "heart")
    }
}
```

When someone activates the context menu with an action like touch and
hold in iOS or iPadOS, the system uses the [`Image`](/documentation/SwiftUI/Image) as the preview for
the context menu, applying the requested corner radius.

The content shape also supports applying modifiers such as
[`inset(by:)`](/documentation/SwiftUI/InsettableShape/inset(by:)) to add padding.

> Note: Similar to ``doc://com.apple.SwiftUI/documentation/SwiftUI/ContentShapeKinds/focusEffect``,
> the ``doc://com.apple.SwiftUI/documentation/SwiftUI/ContentShapeKinds/contextMenuPreview`` and
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/ContentShapeKinds/dragPreview`` content shapes do not impact the
> hit-testing shape. In this example, someone can touch and hold anywhere
> on the ``doc://com.apple.SwiftUI/documentation/SwiftUI/VStack`` to activate the menu. If you only want the ``doc://com.apple.SwiftUI/documentation/SwiftUI/Image``
> to activate the menu, apply ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/contextMenu(menuItems:)`` to the
> ``doc://com.apple.SwiftUI/documentation/SwiftUI/Image`` instead.

---

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)