<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GraphicsContext/Shading/linearGradient(_:startPoint:endPoint:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV7ShadingV14linearGradient_10startPoint03endI07optionsAeA03AnyG0V_So7CGPointVAmC0G7OptionsVtFZ::OverloadGroup"
  },
  "title" : "linearGradient(_:startPoint:endPoint:options:)"
}
-->

# linearGradient(_:startPoint:endPoint:options:)

Returns a shading instance that fills a linear (axial) gradient.

```
static func linearGradient(_ gradient: AnyGradient, startPoint: CGPoint, endPoint: CGPoint, options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading
```

## Parameters

`gradient`

An [`AnyGradient`](/documentation/SwiftUI/AnyGradient) instance that defines the colors
of the gradient.

`startPoint`

The start point of the gradient axis.

`endPoint`

The end point of the gradient axis.

`options`

Options that you use to configure the gradient.

## Return Value

A shading instance filled with a linear gradient.

## Discussion

The shading instance defines an axis from `startPoint` to `endPoint`
in the current user space and maps colors from `gradient`
to lines perpendicular to the axis.

---

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)