---
title: "Button Roles | Explore SwiftUI"
description: "A value that describes the purpose of a button. Learn how to use Button Roles in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
canonical_url: "https://exploreswiftui.com/library/button/button-roles"
meta:
  author: "Explore SwiftUI"
  "og:description": "A value that describes the purpose of a button. Learn how to use Button Roles in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Button%2BRoles%2Cdescription_Explore%2Bvisually%2Bwith%2Bcode%2Bexamples%2Ccategory_Button%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L2J1dHRvbi9idXR0b24tcm9sZXMi%2Cs_GD9zyzpOt0WbYsBo.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Button Roles | Explore SwiftUI"
  "twitter:description": "A value that describes the purpose of a button. Learn how to use Button Roles in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Button%2BRoles%2Cdescription_Explore%2Bvisually%2Bwith%2Bcode%2Bexamples%2Ccategory_Button%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L2J1dHRvbi9idXR0b24tcm9sZXMi%2Cs_GD9zyzpOt0WbYsBo.png"
  "twitter:title": "Button Roles | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone](https://exploreswiftui.com/iphone?element=33) [ Apple TV](https://exploreswiftui.com/tv?element=33) [ Apple Vision Pro](https://exploreswiftui.com/vision-pro?element=33)

# **Button Roles**

A value that describes the purpose of a button.

![Button Roles - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/33/variants/718?v=1790073478842&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 15.0+ iPadOS 15.0+ macOS 12.0+ watchOS 8.0+ tvOS 15.0+ visionOS 1.0+

### **Tags**

### **SwiftUI Code**

[ Docs](https://developer.apple.com/documentation/swiftui/buttonrole)

```
VStack {
    HStack {
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.plain)
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.borderless)
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.bordered)
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.borderedProminent)
    }
    HStack {
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.plain)
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.borderless)
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.bordered)
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.borderedProminent)
    }
}
```

### **Found an issue or have a suggestion?**

Created: May 30, 2025Updated: August 18, 2026

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/button/button-roles#webpage","@type":"WebPage","dateModified":"2026-08-18T13:24:47.465Z","datePublished":"2025-05-30T13:57:24.161Z","description":"A value that describes the purpose of a button. Learn how to use Button Roles in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Button Roles","url":"https://exploreswiftui.com/library/button/button-roles","breadcrumb":{"@id":"https://exploreswiftui.com/library/button/button-roles#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/button/button-roles"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/button/button-roles#article","dateModified":"2026-08-18T13:24:47.465Z","datePublished":"2025-05-30T13:57:24.161Z","description":"A value that describes the purpose of a button. Learn how to use Button Roles in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","headline":"Button Roles","inLanguage":"en-US","name":"Button Roles","thumbnailUrl":"https://exploreswiftui.com/api/images/33/variants/718?v=1790073478842&r=2","url":"https://exploreswiftui.com/library/button/button-roles","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/button/button-roles#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/button/button-roles#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/buttonrole","codeSampleType":"full example","description":"A value that describes the purpose of a button. Learn how to use Button Roles in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Button Roles SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"VStack {\n    HStack {\n        Button(\"Tap Me\", role: .cancel, action: action)\n            .buttonStyle(.plain)\n        Button(\"Tap Me\", role: .cancel, action: action)\n            .buttonStyle(.borderless)\n        Button(\"Tap Me\", role: .cancel, action: action)\n            .buttonStyle(.bordered)\n        Button(\"Tap Me\", role: .cancel, action: action)\n            .buttonStyle(.borderedProminent)\n    }\n    HStack {\n        Button(\"Tap Me\", role: .destructive, action: action)\n            .buttonStyle(.plain)\n        Button(\"Tap Me\", role: .destructive, action: action)\n            .buttonStyle(.borderless)\n        Button(\"Tap Me\", role: .destructive, action: action)\n            .buttonStyle(.bordered)\n        Button(\"Tap Me\", role: .destructive, action: action)\n            .buttonStyle(.borderedProminent)\n    }\n}\n","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Button"},{"@type":"Thing","name":"Button Roles"}]},{"@id":"https://exploreswiftui.com/library/button/button-roles#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Button","item":"https://exploreswiftui.com/library/button","position":2},{"@type":"ListItem","name":"Button Roles","item":"https://exploreswiftui.com/library/button/button-roles","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/33/variants/718?v=1790073478842&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/33/variants/718?v=1790073478842&r=2"}]}
```