import SwiftUI public struct SectionHeaderLabel: View { @Environment(\.sectionHeaderLabelStyle) var style let content: () -> Content public init(@ViewBuilder _ content: @escaping () -> Content) { self.content = content } public var body: some View { style.makeBody( configuration: TextLabelConfiguration( label: TextLabelConfiguration.Label(content: content()) ) ) } } extension SectionHeaderLabel where Content == Text { public init(_ text: LocalizedStringKey) { self.init { Text(text) } } public init(_ text: S) where S: StringProtocol { self.init { Text(text) } } } #Preview { Form { Section { Text("Content") } header: { SectionHeaderLabel("One") } Section { Text("Content") } header: { SectionHeaderLabel("Two") } } .formStyle(.grouped) #if os(macOS) .frame(width: 400, height: 400) #endif }