---
title: "Color Gradient | Explore SwiftUI"
description: "The Color gradient modifier. Learn how to use Color Gradient in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
canonical_url: "https://exploreswiftui.com/library/color/color-gradient"
meta:
  author: "Explore SwiftUI"
  "og:description": "The Color gradient modifier. Learn how to use Color Gradient in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Color%2BGradient%2Cdescription_The%2BColor%2Bgradient%2Bmodifier%2Ccategory_Color%2Cimage_~L2FwaS9pbWFnZXMvMTUvdmFyaWFudHMvMTQzP3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L2NvbG9yL2NvbG9yLWdyYWRpZW50Ig%2Cs_plaRahtOA_l1EtK9.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Color Gradient | Explore SwiftUI"
  "twitter:description": "The Color gradient modifier. Learn how to use Color Gradient in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Color%2BGradient%2Cdescription_The%2BColor%2Bgradient%2Bmodifier%2Ccategory_Color%2Cimage_~L2FwaS9pbWFnZXMvMTUvdmFyaWFudHMvMTQzP3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L2NvbG9yL2NvbG9yLWdyYWRpZW50Ig%2Cs_plaRahtOA_l1EtK9.png"
  "twitter:title": "Color Gradient | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone](https://exploreswiftui.com/iphone?element=15)

# **Color Gradient**

The Color gradient modifier

![Color Gradient - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/15/variants/143?v=1790073478842&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 16.0+ iPadOS 16.0+ macOS 13.0+ watchOS 9.0+ tvOS 16.0+ visionOS 1.0+

### **Tags**

### **SwiftUI Code**

[ Docs](https://developer.apple.com/documentation/swiftui/color/gradient)

```
VStack {
  HStack {
    smallRect
      .foregroundStyle(.blue)
    smallRect
      .foregroundStyle(.blue.secondary)
    smallRect
      .foregroundStyle(.blue.tertiary)
    smallRect
      .foregroundStyle(.blue.quaternary)
    smallRect
      .foregroundStyle(.blue.quinary)
  }
  HStack {
    smallRect
      .foregroundStyle(.blue.gradient)
    smallRect
      .foregroundStyle(.blue.gradient.secondary)
    smallRect
      .foregroundStyle(.blue.gradient.tertiary)
    smallRect
      .foregroundStyle(.blue.gradient.quaternary)
    smallRect
      .foregroundStyle(.blue.gradient.quinary)
  }
  HStack {
    smallRect
      .foregroundStyle(.blue.gradient.opacity(0.9))
    smallRect
      .foregroundStyle(.blue.gradient.opacity(0.7))
    smallRect
      .foregroundStyle(.blue.gradient.tertiary.opacity(0.5))
    smallRect
      .foregroundStyle(.blue.gradient.quaternary.opacity(0.3))
    smallRect
      .foregroundStyle(.blue.gradient.quinary.opacity(0.1))
  }
}
```

### **Found an issue or have a suggestion?**

Created: May 29, 2025Updated: May 30, 2025

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

### **More Color Components **

[**View all **](https://exploreswiftui.com/library/color)

![Color Opacity - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/16/variants/124?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Color Opacity**

The Color opacity modifier

![UIKit Separator Colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/14/variants/57?v=1790073478842&r=2&w=412&q=75&f=webp)

### **UIKit Separator Colors**

The UIKit separator colors that are also used in other components, such as the TextField

![UIKit Content Background colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/13/variants/53?v=1790073478842&r=2&w=412&q=75&f=webp)

### **UIKit Content Background colors**

The UIKit colors that are also used in other components like in List and GroupBox

![UIKit Text Colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/12/variants/55?v=1790073478842&r=2&w=412&q=75&f=webp)

### **UIKit Text Colors**

The UIKit text colors that are also used in other components, such as the TextField

![UIKit Fill Colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/11/variants/43?v=1790073478842&r=2&w=412&q=75&f=webp)

### **UIKit Fill Colors**

![UIKit Label Colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/10/variants/45?v=1790073478842&r=2&w=412&q=75&f=webp)

### **UIKit Label Colors**

![Color Variants - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/9/variants/209?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Color Variants**

HierarchicalShapeStyle, a shape style that maps to one of the numbered content styles

![Semantic Colors - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/8/variants/51?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Semantic Colors**

### **Explore Other Components **

[**Browse all **](https://exploreswiftui.com/)

![MenuControlGroupStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/55/variants/99?v=1790073478842&r=2&w=412&q=75&f=webp)

### **MenuControlGroupStyle**

A control group style that presents its content as a menu when the user presses the control, or as a submenu when nested within a larger menu

![Disclosure Group - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/131/variants/363?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Disclosure Group**

A view that shows or hides another content view, based on the state of a disclosure control.

![Future DatePicker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/68/variants/18?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Future DatePicker**

Creates an instance that selects multiple dates on or after some start date

![RenameButton - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/37/variants/213?v=1790073478842&r=2&w=412&q=75&f=webp)

### **RenameButton**

A button that triggers a standard rename action

![Outline Group - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/132/variants/371?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Outline Group**

A structure that computes views and disclosure groups on demand from an underlying collection of tree-structured, identified data.

![EllipticalListStyle - watchOS - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/103/variants/327?v=1790073478842&r=2&w=412&q=75&f=webp)

### **EllipticalListStyle**

The list style that describes the behavior and appearance of an elliptical list.

![Divider - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/69/variants/69?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Divider**

A visual element that can be used to separate other content

![Axis Behavior - iOS on iPhone Duo - Landscape - Closed - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/247/variants/1692?v=1790586402346&r=2&w=412&q=75&f=webp)

### **Axis Behavior**

The bar axis behavior of the toolbar item.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/color/color-gradient#webpage","@type":"WebPage","dateModified":"2025-05-30T06:11:20.606Z","datePublished":"2025-05-29T11:31:10.283Z","description":"The Color gradient modifier. Learn how to use Color Gradient in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Color Gradient","url":"https://exploreswiftui.com/library/color/color-gradient","breadcrumb":{"@id":"https://exploreswiftui.com/library/color/color-gradient#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/color/color-gradient"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/color/color-gradient#article","dateModified":"2025-05-30T06:11:20.606Z","datePublished":"2025-05-29T11:31:10.283Z","description":"The Color gradient modifier. Learn how to use Color Gradient in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","headline":"Color Gradient","inLanguage":"en-US","name":"Color Gradient","thumbnailUrl":"https://exploreswiftui.com/api/images/15/variants/143?v=1790073478842&r=2","url":"https://exploreswiftui.com/library/color/color-gradient","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/color/color-gradient#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/color/color-gradient#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/color/gradient","codeSampleType":"full example","description":"The Color gradient modifier. Learn how to use Color Gradient in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Color Gradient SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"VStack {\n  HStack {\n    smallRect\n      .foregroundStyle(.blue)\n    smallRect\n      .foregroundStyle(.blue.secondary)\n    smallRect\n      .foregroundStyle(.blue.tertiary)\n    smallRect\n      .foregroundStyle(.blue.quaternary)\n    smallRect\n      .foregroundStyle(.blue.quinary)\n  }\n  HStack {\n    smallRect\n      .foregroundStyle(.blue.gradient)\n    smallRect\n      .foregroundStyle(.blue.gradient.secondary)\n    smallRect\n      .foregroundStyle(.blue.gradient.tertiary)\n    smallRect\n      .foregroundStyle(.blue.gradient.quaternary)\n    smallRect\n      .foregroundStyle(.blue.gradient.quinary)\n  }\n  HStack {\n    smallRect\n      .foregroundStyle(.blue.gradient.opacity(0.9))\n    smallRect\n      .foregroundStyle(.blue.gradient.opacity(0.7))\n    smallRect\n      .foregroundStyle(.blue.gradient.tertiary.opacity(0.5))\n    smallRect\n      .foregroundStyle(.blue.gradient.quaternary.opacity(0.3))\n    smallRect\n      .foregroundStyle(.blue.gradient.quinary.opacity(0.1))\n  }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Color"},{"@type":"Thing","name":"Color Gradient"}]},{"@id":"https://exploreswiftui.com/library/color/color-gradient#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Color","item":"https://exploreswiftui.com/library/color","position":2},{"@type":"ListItem","name":"Color Gradient","item":"https://exploreswiftui.com/library/color/color-gradient","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/15/variants/143?v=1790073478842&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/15/variants/143?v=1790073478842&r=2"}]}
```