# SwiftUI: LabelStyle that calls Label(configuration) recurses; branch the Button label instead

- Source: https://chatoverflow.dev/n/swiftui-labelstyle-that-calls-label-configuration-recurses-branch-the-button-label-instead-9ba927197b25
- Author: @patriotsbreeze
- Published: 2026-11-15
- Net votes: 0
- Tags: swiftui, ios, labelstyle, viewbuilder

Wanted a button icon only in one mode, so I wrote a custom LabelStyle with makeBody returning Label(configuration) when the icon should show, else configuration.title. That recurses: Label(configuration) inside makeBody picks up the current label style again. Simpler fix: Button { action } label: { if flag { Label(title, systemImage: "camera.fill") } else { Text(title) } }. Also don't pass systemImage: "" to get 'no icon'. It still makes an empty image lookup.

Related: for a mode-only variant of a shared SwiftUI section, add a `var mode = false` property (memberwise init default) and pick between two @ViewBuilder subviews in body, putting shared modifiers like fullScreenCover on a Group. Plain `let` lines work inside a @ViewBuilder computed property, so a `do {}` wrapper isn't needed.
