TechnologiesSwiftUI

PlainButtonStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 13.0+✓ renders

A button style that doesn't style or decorate its content while idle, but

How it works

PlainButtonStyle is a built-in button style that removes the decoration SwiftUI would otherwise apply to a button — no tint-colored label, no filled background, no platform chrome. It presents a button as plain content, leaving the label to render with whatever appearance you give it, while still behaving as a fully interactive control. Reach for it when a button is really a piece of custom content — a row, a card, an icon — that you want to be tappable without looking like a standard system button.

  1. Apply the style with buttonStyle(_:)

    You install a button style by passing an instance to the buttonStyle(_:) modifier on a Button. Constructing PlainButtonStyle() and handing it to .buttonStyle(PlainButtonStyle()) opts the Button("Save") control out of the default styling for the views in that subtree.

  2. Use the .plain shorthand

    Because PlainButtonStyle is a standard style, SwiftUI exposes it through the static accessor .plain, so you can write .buttonStyle(.plain) instead of spelling out the initializer. The Button("Cancel") control uses this shorthand form — it is exactly equivalent to .buttonStyle(PlainButtonStyle()).

  3. Control the appearance yourself

    Because the plain style strips the default tint and background, the label's color is now whatever the surrounding environment provides — and you can override it directly. Chaining .foregroundColor(.red) after .buttonStyle(.plain) on Button("Cancel") shows how the label takes on your color rather than an accent the system would have imposed.

  4. Conforms to ButtonStyle via PrimitiveButtonStyle

    PlainButtonStyle conforms to PrimitiveButtonStyle, the protocol that lets a style define a button's complete look and trigger behavior. That conformance is what makes the value a valid argument to buttonStyle(_:); you typically just construct it and apply it rather than implementing the protocol yourself.

Try it — Delete the .foregroundColor(.red) line on Button("Cancel") and watch its label fall back to the inherited content color, confirming that .plain supplies no color of its own.

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.

PlainButtonStyle.swift
struct PlainButtonStyleDemo: View {
    var body: some View {
        VStack(spacing: 16) {
            Button("Save") {}
                .buttonStyle(PlainButtonStyle())
            Button("Cancel") {}
                .buttonStyle(.plain)
                .foregroundColor(.red)
        }
        .padding()
    }
}
Live preview
Save Cancel
Save Cancel
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →