import SwiftUI struct TitledSection: View where Content: View { private let content: Content private let title: String private let spacing: CGFloat init(title: String, spacing: CGFloat, @ViewBuilder content: () -> Content) { self.title = title self.spacing = spacing self.content = content() } var body: some View { VStack(alignment: .leading, spacing: 0) { Text(title) .font(.title) .fontWeight(.light) .padding(.bottom, spacing) content } } } struct TitledSection_Previews: PreviewProvider { static var previews: some View { TitledSection(title: "Title", spacing: 10) { Text("Some more text") } } }