0Pricing
SwiftUI Academy · Lesson

ButtonStyle & LabelStyle

Build branded, reusable control styles.

Style Controls, Not Instances

Restyling every button by hand gets tedious. A ButtonStyle defines one branded look you reuse across the whole app. 🎨

The ButtonStyle Protocol

Conform a struct to ButtonStyle and implement makeBody. It receives a configuration and returns the styled button.

struct PrimaryStyle: ButtonStyle {
    func makeBody(configuration: Configuration) -> some View {
        configuration.label
    }
}

All lessons in this course

  1. Extracting Reusable Views
  2. Custom ViewModifiers
  3. ButtonStyle & LabelStyle
  4. ViewBuilder & Generic Containers
← Back to SwiftUI Academy