TechnologiesSwiftUI

BorderlessButtonStyle struct

iOSmacOStvOSwatchOSvisionOSiOS 13.0+✓ renders

A button style that doesn't apply a border.

How it works

BorderlessButtonStyle is a concrete ButtonStyle that draws a button with no border, background fill, or bezel, rendering its label as plain tappable content that takes on the accent color. Reach for it when you want a control to read as lightweight in-line text — an action inside a list row, a toolbar, or a stacked form — rather than as a prominent, filled call-to-action. It is the style SwiftUI applies automatically inside containers like lists and menus, and you apply it explicitly when you want that same flat treatment elsewhere.

  1. Apply it with the buttonStyle(_:) modifier

    BorderlessButtonStyle takes effect when you pass an instance of it to the buttonStyle(_:) modifier on a Button. The modifier installs the style into the environment for that button, so the call .buttonStyle(BorderlessButtonStyle()) on the Save button replaces the platform's default chrome with the borderless appearance.

  2. Construct it with the empty initializer

    The type has a single parameterless initializer, BorderlessButtonStyle(). There are no options to configure — the style fully describes the borderless look on its own, which is why the constructor call is bare in .buttonStyle(BorderlessButtonStyle()).

  3. Prefer the .borderless shorthand

    Because BorderlessButtonStyle conforms to ButtonStyle and exposes a matching static member, you can write .borderless instead of spelling out the full type. The Cancel button uses .buttonStyle(.borderless), which is exactly equivalent to passing BorderlessButtonStyle() but reads more naturally in a modifier chain.

  4. Let it cascade through a container

    buttonStyle(_:) propagates down the view hierarchy, so a single application can style every button beneath it. Placing the modifier on the enclosing VStack rather than on each Button would give both Save and Cancel the borderless treatment from one call.

Try it — Change .buttonStyle(.borderless) on the Cancel button to .buttonStyle(.borderedProminent) and compare it against the still-borderless Save button to see how much chrome BorderlessButtonStyle strips away.

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.

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