<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AttributedTextFormattingDefinition/body-1b01t",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI34AttributedTextFormattingDefinitionP4body4BodyQzvp"
  },
  "title" : "body"
}
-->

# body

The constraints of the formatting definition.

```
@AttributedTextFormatting.DefinitionBuilder<Self.Scope> var body: Self.Body { get }
```

## Discussion

When you implement a custom definition, you must implement a computed
`body` property to provide the constraints of your definition. Return a
definition that’s composed of built-in definitions that SwiftUI
provides, such as [`AttributedTextFormattingDefinition.ValueConstraint`](/documentation/SwiftUI/AttributedTextFormattingDefinition/ValueConstraint)
and [`AttributedTextValueConstraint`](/documentation/SwiftUI/AttributedTextValueConstraint)s, plus other composite
[`AttributedTextFormattingDefinition`](/documentation/SwiftUI/AttributedTextFormattingDefinition)s that you’ve already defined:

```
struct MyTextFormattingDefinition: AttributedTextFormattingDefinition {
    var body: some AttributedTextFormattingDefinition<
        AttributeScopes.SwiftUIAttributes
    > {
        ValueConstraint(
            for: \.underlineStyle,
            values: [nil, .single],
            default: .single)
        MyAttributedTextValueConstraint()
    }
}
```

Note that the order of the constraints in the result builder matters
as constraints are applied in order. For details, see
`AttributedTextValueConstraint/constrain(_:)-(Attributes)`.

---

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)