<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "StoreKit",
  "identifier" : "/documentation/StoreKit/ProductView/init(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "StoreKit",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:17_StoreKit_SwiftUI11ProductViewVyACyAA0eF18StyleConfigurationV4IconVAGGAEcAGRszAGRs_rlufc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a view to merchandise an individual product using a configuration for product view style.

```
nonisolated init(_ configuration: ProductViewStyleConfiguration) where Icon == ProductViewStyleConfiguration.Icon, PlaceholderIcon == ProductViewStyleConfiguration.Icon
```

## Parameters

`configuration`

A configuration for a product view style.

## Discussion

Use this initializer within the [`makeBody(configuration:)`](/documentation/StoreKit/ProductViewStyle/makeBody(configuration:)) method of a [`ProductViewStyle`](/documentation/StoreKit/ProductViewStyle) to create an instance of the product view you want to style. This is useful for custom product view styles that modify the current style, rather than implementing a new style.

The following code example shows how to create and use custom styles by composing standard styles:

```swift
struct SpinnerWhenLoadingStyle: ProductViewStyle {
    public func makeBody(configuration: Configuration) -> some View {
        switch configuration.state {
        case .loading:
            ProgressView()
                .progressView(.circular)
        default:
            ProductView(configuration)
        }
    }
}
// Use the following elsewhere in the code.
ProductView(id: "com.example.product")
    .productViewStyle(SpinnerWhenLoadingStyle())
```

---

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)