Library / Taps & buttons

Primary button press

A standard call-to-action button ("Continue", "Add to cart") confirms the press.

0ms 100ms 200ms 300ms 400ms
Feel
One clean medium tap on touch-up. Neutral and mechanical.
APIs
.sensoryFeedback(.impact(weight: .medium))UIImpactFeedbackGenerator(style: .medium)
Minimum OS
iOS 17+ / iOS 10+
Raw .md
SwiftUI (iOS 17+)
import SwiftUI

struct PrimaryButton: View {
    let title: String
    let action: () -> Void
    @State private var pressCount = 0

    var body: some View {
        Button {
            pressCount += 1
            action()
        } label: {
            Text(title)
                .font(.headline)
                .frame(maxWidth: .infinity)
                .padding()
                .background(.blue, in: RoundedRectangle(cornerRadius: 14))
                .foregroundStyle(.white)
        }
        .sensoryFeedback(.impact(weight: .medium), trigger: pressCount)
    }
}
UIKit
let button = UIButton(configuration: .filled())
button.setTitle("Continue", for: .normal)

let haptic = UIImpactFeedbackGenerator(style: .medium)

button.addAction(UIAction { _ in haptic.prepare() }, for: .touchDown)
button.addAction(UIAction { _ in
    haptic.impactOccurred()
    // perform the action
}, for: .touchUpInside)
Copied