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.
Apply the style with buttonStyle(_:)
You install a button style by passing an instance to the
buttonStyle(_:)modifier on aButton. ConstructingPlainButtonStyle()and handing it to.buttonStyle(PlainButtonStyle())opts theButton("Save")control out of the default styling for the views in that subtree.Use the .plain shorthand
Because
PlainButtonStyleis a standard style, SwiftUI exposes it through the static accessor.plain, so you can write.buttonStyle(.plain)instead of spelling out the initializer. TheButton("Cancel")control uses this shorthand form — it is exactly equivalent to.buttonStyle(PlainButtonStyle()).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)onButton("Cancel")shows how the label takes on your color rather than an accent the system would have imposed.Conforms to ButtonStyle via PrimitiveButtonStyle
PlainButtonStyleconforms toPrimitiveButtonStyle, 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 tobuttonStyle(_:); you typically just construct it and apply it rather than implementing the protocol yourself.
.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.
struct PlainButtonStyleDemo: View {
var body: some View {
VStack(spacing: 16) {
Button("Save") {}
.buttonStyle(PlainButtonStyle())
Button("Cancel") {}
.buttonStyle(.plain)
.foregroundColor(.red)
}
.padding()
}
}