Contents

init(_:)

Creates a group box based on a style configuration.

Declaration

nonisolated init(_ configuration: GroupBoxStyleConfiguration)

Parameters

  • configuration:

    The properties of the group box instance being created.

Discussion

Use this initializer within the makeBody(configuration:) method of a GroupBoxStyle instance to create a styled group box, with customizations, while preserving its existing style.

The following example adds a pink border around the group box, without overriding its current style:

struct PinkBorderGroupBoxStyle: GroupBoxStyle {
    func makeBody(configuration: Configuration) -> some View {
        GroupBox(configuration)
            .border(Color.pink)
    }
}