{"id":47965,"date":"2025-06-04T16:34:50","date_gmt":"2025-06-04T20:34:50","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=47965"},"modified":"2025-06-04T16:36:03","modified_gmt":"2025-06-04T20:36:03","slug":"swiftui-macos-sheet-buttons","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/06\/04\/swiftui-macos-sheet-buttons\/","title":{"rendered":"SwiftUI macOS Sheet Buttons"},"content":{"rendered":"<p><a href=\"https:\/\/ohanaware.com\/swift\/macOSSheetButtons.html\">Sam Rowlands<\/a>:<\/p>\n<blockquote cite=\"https:\/\/ohanaware.com\/swift\/macOSSheetButtons.html\"><p>Sheet dialog buttons don&rsquo;t meet the macOS human interface guidelines by default, I&rsquo;ve tried some solutions in the past, but then I stumbled across a really simple way to do it and I&rsquo;m sharing that now.<\/p><p>[&#8230;]<\/p><p>Yes, it&rsquo;s that simple, use a toolbar and the placement attributes to specify which buttons perform which action and SwiftUI will not only place the buttons correctly, but will resize the default and cancel buttons to match the Apple Human Interface Guidelines.<\/p><\/blockquote>\n\n<p>Except now the window shows a horizontal line for the toolbar. Still, this is the easiest way I&rsquo;ve seen so far.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2025\/04\/29\/swiftui-macos-toolbar-examples\/\">SwiftUI macOS Toolbar Examples<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/03\/11\/mac-dialog-in-auto-layout-vs-swiftui\/\">Mac Dialog in Auto Layout vs. SwiftUI<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2022\/05\/31\/swiftui-equal-and-ideal-sizes\/\">SwiftUI Equal and Ideal Sizes<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/08\/06\/emulating-equal-size-constraints-in-swiftui\/\">Emulating Equal-Size Constraints in SwiftUI<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Sam Rowlands: Sheet dialog buttons don&rsquo;t meet the macOS human interface guidelines by default, I&rsquo;ve tried some solutions in the past, but then I stumbled across a really simple way to do it and I&rsquo;m sharing that now.[&#8230;]Yes, it&rsquo;s that simple, use a toolbar and the placement attributes to specify which buttons perform which action [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-06-04T20:34:52Z","apple_news_api_id":"f15dd7b5-e5df-4de5-95f2-4e7ed6684d75","apple_news_api_modified_at":"2025-06-04T20:34:52Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A8V3XteXfTeWV8k5-1mhNdQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[30,2598,71,901,1812],"class_list":["post-47965","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-mac","tag-macos-15-sequoia","tag-programming","tag-swift-programming-language","tag-swiftui"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=47965"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47965\/revisions"}],"predecessor-version":[{"id":47966,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47965\/revisions\/47966"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=47965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=47965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=47965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}