---
title: "linearGradient(_:startPoint:endPoint:options:)"
framework: swiftui
role: symbol
role_heading: Type Method
path: "swiftui/graphicscontext/shading/lineargradient(_:startpoint:endpoint:options:)"
---

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

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

## Declaration

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

## Parameters

- `gradient`: An doc://com.apple.SwiftUI/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

Return Value A shading instance filled with a linear gradient.

## Discussion

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.

## See Also

### Gradients

- [radialGradient(_:center:startRadius:endRadius:options:)](swiftui/graphicscontext/shading/radialgradient(_:center:startradius:endradius:options:).md)
- [conicGradient(_:center:angle:options:)](swiftui/graphicscontext/shading/conicgradient(_:center:angle:options:).md)
