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

# linearGradient(_:startPoint:endPoint:)

A linear gradient.

## Declaration

```swift
static func linearGradient(_ gradient: AnyGradient, startPoint: UnitPoint, endPoint: UnitPoint) -> some ShapeStyle

```

## Discussion

Discussion The gradient applies the color function along an axis, as defined by its start and end points. The gradient maps the unit space points into the bounding rectangle of each shape filled with the gradient. For example, a linear gradient used as a background: ContentView()     .background(.linearGradient(.red.gradient,         startPoint: .top, endPoint: .bottom)) For information about how to use shape styles, see ShapeStyle.

## See Also

### Linear gradients

- [linearGradient(colors:startPoint:endPoint:)](swiftui/shapestyle/lineargradient(colors:startpoint:endpoint:).md)
- [linearGradient(stops:startPoint:endPoint:)](swiftui/shapestyle/lineargradient(stops:startpoint:endpoint:).md)
