---
title: "init(_:red:green:blue:opacity:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/color/init(_:red:green:blue:opacity:)"
---

# init(_:red:green:blue:opacity:)

Creates a constant color from red, green, and blue component values.

## Declaration

```swift
init(_ colorSpace: Color.RGBColorSpace = .sRGB, red: Double, green: Double, blue: Double, opacity: Double = 1)
```

## Parameters

- `colorSpace`: The profile that specifies how to interpret the color for display. The default is doc://com.apple.SwiftUI/documentation/SwiftUI/Color/RGBColorSpace/sRGB.
- `red`: The amount of red in the color.
- `green`: The amount of green in the color.
- `blue`: The amount of blue in the color.
- `opacity`: An optional degree of opacity, given in the range 0 to 1. A value of 0 means 100% transparency, while a value of 1 means 100% opacity. The default is 1.

## Discussion

Discussion This initializer creates a constant color that doesn’t change based on context. For example, it doesn’t have distinct light and dark appearances, unlike various system-defined colors, or a color that you load from an Asset Catalog with init(_:bundle:). A standard sRGB color space clamps each color component — red, green, and blue — to a range of 0 to 1, but SwiftUI colors use an extended sRGB color space, so you can use component values outside that range. This makes it possible to create colors using the Color.RGBColorSpace.sRGB or Color.RGBColorSpace.sRGBLinear color space that make full use of the wider gamut of a diplay that supports Color.RGBColorSpace.displayP3.

## See Also

### 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)
- [Color.RGBColorSpace](swiftui/color/rgbcolorspace.md)
