<!--
{
  "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(_:white:opacity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI15GraphicsContextV7ShadingV5color_5white7opacityAeA5ColorV13RGBColorSpaceO_S2dtFZ"
  },
  "title" : "color(_:white:opacity:)"
}
-->

# color(_:white:opacity:)

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

```
static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, white: 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).

`white`

The value to use for each of the red, green, and blue
components 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)