<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GraphicsContext/Shading/color(_:red:green:blue:opacity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV7ShadingV5color_3red5green4blue7opacityAeA5ColorV13RGBColorSpaceO_S4dtFZ"
  },
  "title" : "color(_:red:green:blue:opacity:)"
}
-->

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

Returns a shading instance that fills with a color in the given
color space.

```
static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, red: Double, green: Double, blue: Double, opacity: Double = 1) -> GraphicsContext.Shading
```

## Parameters

`colorSpace`

The RGB color space used to define the color. The
default is [`Color.RGBColorSpace.sRGB`](/documentation/SwiftUI/Color/RGBColorSpace/sRGB).

`red`

The red component of the color.

`green`

The green component of the color.

`blue`

The blue component of the color.

`opacity`

The opacity of the color. The default is `1`, which
means fully opaque.

## Return Value

A shading instance filled with a color.

---

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)