<!--
{
  "availability" : [
    "MapKit JS: 5.45.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/LineGradient",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "cl/mapkit.LineGradient"
  },
  "title" : "LineGradient"
}
-->

# LineGradient

A line that displays with a gradient along the length of the line.

```
class LineGradient
```

## Overview

Use [`LineGradient`](/documentation/MapKitJS/LineGradient) with a [`PolylineOverlay`](/documentation/MapKitJS/PolylineOverlay) to show a gradient along a route or path. You can also use it to provide additional information about locations along the path, for example, the running pace along a route.

## Topics

### Creating a Line Gradient

[`constructor(colorStops?: Record<number, string>);`](/documentation/MapKitJS/LineGradient/LineGradientConstructor)

Creates a style that renders a gradient along the length of a line.

[`addColorStop(offset: number, color: string): void;`](/documentation/MapKitJS/LineGradient/addColorStop)

Adds a color transition point to the gradient.

[`addColorStopAtIndex(index: number, color: string): void;`](/documentation/MapKitJS/LineGradient/addColorStopAtIndex)

Adds a color transition at the index point in the list of points within a polyline.

### Instance Methods

[`toString(): string;`](/documentation/MapKitJS/LineGradient/toString)

Returns a string representation of the line gradient object.

---

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)