---
title: "colorSpace(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/anygradient/colorspace(_:)"
---

# colorSpace(_:)

Returns a version of the gradient that will use a specified color space for interpolating between its colors.

## Declaration

```swift
func colorSpace(_ space: Gradient.ColorSpace) -> AnyGradient
```

## Parameters

- `space`: The color space the new gradient will use to interpolate its constituent colors.

## Return Value

Return Value A new gradient that interpolates its colors in the specified color space.

## Discussion

Discussion Rectangle().fill(.linearGradient(     colors: [.white, .blue]).colorSpace(.perceptual))
