TechnologiesSwiftUI

DefaultButtonLabel struct

iOSmacOStvOSwatchOSvisionOSiOS 26.0+✓ renders

The default label to use for a button.

How it works

DefaultButtonLabel is the view that SwiftUI uses to present a button's content with the system's standard label treatment. When you write a button with a string or a view, SwiftUI wraps that content so it can apply the default styling, layout, and behavior a button is expected to have. You rarely name DefaultButtonLabel directly; instead you reach for it conceptually whenever you rely on the built-in look of a Button or expose its content to a button style through the style configuration's label.

  1. Provide content to a Button

    A button's label is whatever you pass as its content. SwiftUI takes that content and produces the default label presentation behind the scenes. In the example, the string "Increment" passed to Button("Increment") becomes the labeled content that the default label renders.

  2. Pair the label with an action

    The label is only the visible part of a button; the trailing closure supplies the work. Here count += 1 runs when the rendered label is tapped, so the default label and the count update together form the complete Button.

  3. Let a button style decorate the label

    Applying a style tells SwiftUI how to dress the default label — its background, foreground, and shape. The .buttonStyle(.borderedProminent) modifier wraps the "Increment" label in the prominent bordered treatment without you reconstructing the label yourself.

  4. Observe the label respond to state

    Because the label is a real view in the hierarchy, it participates in state-driven updates and feedback like press and disabled states. As @State private var count changes, the surrounding Text("Taps: \(count)") redraws while the button's default label stays consistent across taps.

Try it — Replace the string in Button("Increment") with a view label such as Button { count += 1 } label: { Label("Increment", systemImage: "plus") } to see the default label treatment carry over to richer content.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

DefaultButtonLabel.swift
struct DefaultButtonLabelDemo: View {
    @State private var count = 0

    var body: some View {
        VStack(spacing: 16) {
            Text("Taps: \(count)")
                .font(.headline)
            Button("Increment") {
                count += 1
            }
            .buttonStyle(.borderedProminent)
        }
        .padding()
    }
}
Live preview
Taps: 0 Increment
Taps: 0 Increment
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →