---
title: Color
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/color
---

# Color

A representation of a color that adapts to a given context.

## Declaration

```swift
@frozen struct Color
```

## Mentioned in

Laying out a simple view

## Overview

Overview You can create a color in one of several ways: Load a color from an Asset Catalog: let aqua = Color("aqua") // Looks in your app's main bundle by default. Specify component values, like red, green, and blue; hue, saturation, and brightness; or white level: let skyBlue = Color(red: 0.4627, green: 0.8392, blue: 1.0) let lemonYellow = Color(hue: 0.1639, saturation: 1, brightness: 1) let steelGray = Color(white: 0.4745) Create a color instance from another color, like a UIColor or an NSColor: #if os(iOS) let linkColor = Color(uiColor: .link) #elseif os(macOS) let linkColor = Color(nsColor: .linkColor) #endif Use one of a palette of predefined colors, like black, green, and purple. Some view modifiers can take a color as an argument. For example, foregroundStyle(_:) uses the color you provide to set the foreground color for view elements, like text or SF Symbols: Image(systemName: "leaf.fill")     .foregroundStyle(Color.green)

Because SwiftUI treats colors as View instances, you can also directly add them to a view hierarchy. For example, you can layer a rectangle beneath a sun image using colors defined above: ZStack {     skyBlue     Image(systemName: "sun.max.fill")         .foregroundStyle(lemonYellow) } .frame(width: 200, height: 100) A color used as a view expands to fill all the space it’s given, as defined by the frame of the enclosing ZStack in the above example:

SwiftUI only resolves a color to a concrete value just before using it in a given environment. This enables a context-dependent appearance for system defined colors, or those that you load from an Asset Catalog. For example, a color can have distinct light and dark variants that the system chooses from at render time.

## Topics

### Creating a color

- [init(_:bundle:)](swiftui/color/init(_:bundle:).md)
- [init(_:)](swiftui/color/init(_:).md)
- [resolve(in:)](swiftui/color/resolve(in:).md)

### Creating a color from component values

- [init(hue:saturation:brightness:opacity:)](swiftui/color/init(hue:saturation:brightness:opacity:).md)
- [init(_:white:opacity:)](swiftui/color/init(_:white:opacity:).md)
- [init(_:red:green:blue:opacity:)](swiftui/color/init(_:red:green:blue:opacity:).md)
- [Color.RGBColorSpace](swiftui/color/rgbcolorspace.md)

### Creating a color from another color

- [init(uiColor:)](swiftui/color/init(uicolor:).md)
- [init(nsColor:)](swiftui/color/init(nscolor:).md)
- [init(cgColor:)](swiftui/color/init(cgcolor:).md)

### Getting standard colors

- [black](swiftui/color/black.md)
- [blue](swiftui/color/blue.md)
- [brown](swiftui/color/brown.md)
- [clear](swiftui/color/clear.md)
- [cyan](swiftui/color/cyan.md)
- [gray](swiftui/color/gray.md)
- [green](swiftui/color/green.md)
- [indigo](swiftui/color/indigo.md)
- [mint](swiftui/color/mint.md)
- [orange](swiftui/color/orange.md)
- [pink](swiftui/color/pink.md)
- [purple](swiftui/color/purple.md)
- [red](swiftui/color/red.md)
- [teal](swiftui/color/teal.md)
- [white](swiftui/color/white.md)
- [yellow](swiftui/color/yellow.md)

### Getting semantic colors

- [accentColor](swiftui/color/accentcolor.md)
- [primary](swiftui/color/primary.md)
- [secondary](swiftui/color/secondary.md)

### Modifying a color

- [opacity(_:)](swiftui/color/opacity(_:).md)
- [gradient](swiftui/color/gradient.md)
- [mix(with:by:in:)](swiftui/color/mix(with:by:in:).md)
- [exposureAdjust(_:)](swiftui/color/exposureadjust(_:).md)
- [headroom(_:)](swiftui/color/headroom(_:).md)

### Working with high dynamic range (HDR) colors

- [resolveHDR(in:)](swiftui/color/resolvehdr(in:).md)
- [Color.ResolvedHDR](swiftui/color/resolvedhdr.md)

### Describing a color

- [description](swiftui/color/description.md)

### Comparing colors

- [==(_:_:)](swiftui/color/==(_:_:).md)
- [hash(into:)](swiftui/color/hash(into:).md)

### Deprecated symbols

- [cgColor](swiftui/color/cgcolor.md)

### Default Implementations

- [ShapeStyle Implementations](swiftui/color/shapestyle-implementations.md)
- [Transferable Implementations](swiftui/color/transferable-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [ShapeStyle](swiftui/shapestyle.md)
- [Transferable](coretransferable/transferable.md)
- [View](swiftui/view.md)

## See Also

### Setting a color

- [tint(_:)](swiftui/view/tint(_:).md)
