<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GroupBox",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI8GroupBoxV"
  },
  "title" : "GroupBox"
}
-->

# GroupBox

A stylized view, with an optional label, that visually collects a logical
grouping of content.

```
nonisolated struct GroupBox<Label, Content> where Label : View, Content : View
```

## Overview

Use a group box when you want to visually distinguish a portion of your
user interface with an optional title for the boxed content.

The following example sets up a `GroupBox` with the label “End-User
Agreement”, and a long `agreementText` string in a [`Text`](/documentation/SwiftUI/Text) view
wrapped by a [`ScrollView`](/documentation/SwiftUI/ScrollView). The box also contains a
[`Toggle`](/documentation/SwiftUI/Toggle) for the user to interact with after reading the text.

```
var body: some View {
    GroupBox(label:
        Label("End-User Agreement", systemImage: "building.columns")
    ) {
        ScrollView(.vertical, showsIndicators: true) {
            Text(agreementText)
                .font(.footnote)
        }
        .frame(height: 100)
        Toggle(isOn: $userAgreed) {
            Text("I agree to the above terms")
        }
    }
}
```

![An iOS status bar above a gray rounded rectangle region marking the bounds](images/com.apple.SwiftUI/SwiftUI-GroupBox-EULA@2x.png)

## Topics

### Creating a group box

[`init(content:)`](/documentation/SwiftUI/GroupBox/init(content:))

Creates an unlabeled group box with the provided view content.

[`init(content:label:)`](/documentation/SwiftUI/GroupBox/init(content:label:))

Creates a group box with the provided label and view content.

[`init(_:content:)`](/documentation/SwiftUI/GroupBox/init(_:content:))

Creates a group box with the provided view content and title.

### Creating a group box from a configuration

[`init(_:)`](/documentation/SwiftUI/GroupBox/init(_:))

Creates a group box based on a style configuration.

### Deprecated initializers

[`init(label:content:)`](/documentation/SwiftUI/GroupBox/init(label:content:))



---

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)