GroupBox
A stylized view, with an optional label, that visually collects a logical grouping of content.
Declaration
Initializers
3 SwiftUI initializers back <GroupBox>. The props you pass pick one.
<GroupBox>
children?: ReactNode
</GroupBox>nonisolated init(@ContentBuilder content: () -> Content)childrenReactNodeContent. Strings become
Text; React Native views are laid out by Yoga and placed by SwiftUI.Swift
content: () -> Content
Also takes the common view props: modifiers, style and testID.
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 SwiftUI.Text view
wrapped by a SwiftUI.ScrollView. The box also contains a
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")
}
}
}From Apple’s SwiftUI documentation. Code samples there are Swift.
Relationships
Conforms to
- View
See also
More in Views.
- ArrangementViewA view that arranges primary and secondary content using an adaptive layout that responds to the environment.
- ControlGroupA container view that displays semantically-related controls in a visually-appropriate manner for the context
- DividerA visual element that can be used to separate other content.
- EditButtonA button that toggles the edit mode environment value.
- EmptyViewA view that doesn't contain any content.
- GaugeA view that shows a value within a range.
- GroupA type that collects multiple instances of a content type --- like views, scenes, or commands --- into a single unit.
- RenameButtonA button that triggers a standard rename action.
- SwipeActionsSwipe actions of a list row (SwiftUI swipeActions(edge:allowsFullSwipe:content:)). Place it inside a List.
- TimelineViewA view that updates according to a schedule that you provide.
- ViewThatFitsA view that adapts to the available space by providing the first child view that fits.