<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/ChartContentBuilder/buildIf(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts19ChartContentBuilderV7buildIfyxSgAeA0bC0RzlFZ"
  },
  "title" : "buildIf(_:)"
}
-->

# buildIf(_:)

Builds a partial result that’s conditionally present.

```
static func buildIf<T>(_ content: T?) -> T? where T : ChartContent
```

## Parameters

`content`

The content to use if the condition is `true`.

## Discussion

This method provides support for `if` statements. It produces optional
chart content that is visible only when the condition evaluates to `true`.

---

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)