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

# stroke(_:with:lineWidth:)

Draws a path into the context with a specified line width.

```
func stroke(_ path: Path, with shading: GraphicsContext.Shading, lineWidth: CGFloat = 1)
```

## Parameters

`path`

The path to outline.

`shading`

The color or pattern to use when outlining the `path`.

`lineWidth`

The width of the stroke, which defaults to `1`.

## Discussion

When you call this method, all [`StrokeStyle`](/documentation/SwiftUI/StrokeStyle) properties other than
[`lineWidth`](/documentation/SwiftUI/StrokeStyle/lineWidth) take their default values. To control other
style properties, use [`stroke(_:with:style:)`](/documentation/SwiftUI/GraphicsContext/stroke(_:with:style:)) 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)