├── LICENSE ├── README.md ├── SwiftUIWindowStylesApp.swift └── previews ├── macOS11 ├── 1-1.png ├── 1-2.png ├── 1-3.png ├── 1-4.png ├── 2-1.png ├── 2-2.png ├── 2-3.png ├── 2-4.png ├── 3-1.png ├── 3-2.png ├── 3-3.png └── 3-4.png └── macOS12 ├── 1-1-automatic-automatic.png ├── 1-2-automatic-expanded.png ├── 1-3-automatic-unified.png ├── 1-4-automatic-unifiedCompact.png ├── 2-1-hiddenTitleBar-automatic.png ├── 2-2-hiddenTitleBar-expanded.png ├── 2-3-hiddenTitleBar-unified.png ├── 2-4-hiddenTitleBar-unifiedCompact.png ├── 3-1-titleBar-automatic.png ├── 3-2-titleBar-expanded.png ├── 3-3-titleBar-unified.png └── 3-4-titleBar-unifiedCompact.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020–2021 Martin Lexow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftUI .windowStyle() .windowToolbarStyle() 2 | 3 | Showcase of window and toolbar styles on macOS using SwiftUI. 4 | 5 | **→ HOW TO:** Add the `.windowStyle()` and/or `.windowToolbarStyle()` modifiers to `WindowGroup` within you `App` struct: 6 | ```swift 7 | WindowGroup { /* ... */ } 8 | .windowStyle(.automatic) 9 | .windowToolbarStyle(.automatic) 10 | ``` 11 | 12 | 🧑‍💻 Have a look at the [SwiftUI source file](https://github.com/martinlexow/SwiftUIWindowStyles/blob/main/SwiftUIWindowStylesApp.swift) in order to see how to create the toolbar etc. 13 | 14 | 🦖 If you are an AppKit developer you might find this helpful as well: [NSWindowStyles](https://github.com/lukakerr/NSWindowStyles). 15 | 16 | Feel free to make a pull request if you have a style to add. 17 | 18 | ## .windowStyle(.automatic) 19 | 20 | ### .windowToolbarStyle(.automatic) 21 | ![](previews/macOS12/1-1-automatic-automatic.png) 22 | 23 | ### .windowToolbarStyle(.expanded) 24 | ![](previews/macOS12/1-2-automatic-expanded.png) 25 | 26 | ### .windowToolbarStyle(.unified) 27 | ![](previews/macOS12/1-3-automatic-unified.png) 28 | 29 | ### .windowToolbarStyle(.unifiedCompact) 30 | ![](previews/macOS12/1-4-automatic-unifiedCompact.png) 31 | 32 | 33 | ## .windowStyle(.hiddenTitleBar) 34 | 35 | ### .windowToolbarStyle(.automatic) 36 | ![](previews/macOS12/2-1-hiddenTitleBar-automatic.png) 37 | 38 | ### .windowToolbarStyle(.expanded) 39 | ![](previews/macOS12/2-2-hiddenTitleBar-expanded.png) 40 | 41 | ### .windowToolbarStyle(.unified) 42 | ![](previews/macOS12/2-3-hiddenTitleBar-unified.png) 43 | 44 | ### .windowToolbarStyle(.unifiedCompact) 45 | ![](previews/macOS12/2-4-hiddenTitleBar-unifiedCompact.png) 46 | 47 | 48 | ## .windowStyle(.titleBar) 49 | 50 | ### .windowToolbarStyle(.automatic) 51 | ![](previews/macOS12/3-1-titleBar-automatic.png) 52 | 53 | ### .windowToolbarStyle(.expanded) 54 | ![](previews/macOS12/3-2-titleBar-expanded.png) 55 | 56 | ### .windowToolbarStyle(.unified) 57 | ![](previews/macOS12/3-3-titleBar-unified.png) 58 | 59 | ### .windowToolbarStyle(.unifiedCompact) 60 | ![](previews/macOS12/3-4-titleBar-unifiedCompact.png) 61 | 62 | 63 | ## About 64 | I’m [Martin](https://martinlexow.de), an indie dev from Berlin. Enjoying my work? Have a look at some great apps of mine on the [Mac App Store](https://apps.apple.com/developer/id955848754) 🌀 65 | -------------------------------------------------------------------------------- /SwiftUIWindowStylesApp.swift: -------------------------------------------------------------------------------- 1 | 2 | 3 | import SwiftUI 4 | 5 | 6 | @main 7 | struct SwiftUIWindowStylesApp: App { 8 | 9 | var body: some Scene { 10 | 11 | WindowGroup { 12 | 13 | VStack { 14 | Color.accentColor.frame(height: 180.0) 15 | .overlay(Text(verbatim: "some_content_below_titlebar") 16 | .foregroundColor(.white).opacity(0.42) 17 | .rotationEffect(Angle(degrees: -9.0)) 18 | .offset(y: 23.0)) 19 | VStack(alignment: .leading) { 20 | Text(verbatim: ".windowStyle(") + Text(verbatim: ".titleBar").fontWeight(.bold) + Text(verbatim: ")") 21 | Text(verbatim: ".windowToolbarStyle(") + Text(verbatim: ".unified").fontWeight(.bold) + Text(verbatim: ")") 22 | Spacer() 23 | } 24 | .padding([.top], 42.0) 25 | .foregroundColor(.accentColor) 26 | .font(Font.system(size: 23.0, weight: .regular, design: .monospaced)) 27 | } 28 | .font(Font.body.monospaced()) 29 | .edgesIgnoringSafeArea(.top) 30 | .navigationTitle("navigationTitle") 31 | .navigationSubtitle("navigationSubtitle") 32 | .toolbar { 33 | 34 | ToolbarItemGroup(placement: .automatic, content: { 35 | Image(systemName: "photo.on.rectangle").imageScale(.large) 36 | Text(verbatim: "some_text") 37 | }) 38 | 39 | ToolbarItemGroup(placement: .navigation, content: { 40 | Button(action: {}, label: { 41 | Text(verbatim: "navigation") 42 | }) 43 | }) 44 | 45 | ToolbarItemGroup(placement: .primaryAction, content: { 46 | Button(action: {}, label: { 47 | Image(systemName: "square.stack.3d.down.forward.fill") 48 | Text(verbatim: "image_button") 49 | }) 50 | }) 51 | 52 | ToolbarItemGroup(placement: .destructiveAction, content: { 53 | Button(action: {}, label: { 54 | Text(verbatim: "button") 55 | }) 56 | }) 57 | 58 | // ToolbarItemGroup(placement: .principal, content: { 59 | // Button(action: {}, label: { 60 | // Text(verbatim: "principal") 61 | // }) 62 | // }) 63 | 64 | // ToolbarItemGroup(placement: .status, content: { 65 | // Button(action: {}, label: { 66 | // Text(verbatim: "status") 67 | // }) 68 | // }) 69 | 70 | // ToolbarItemGroup(placement: .confirmationAction, content: { 71 | // Button(action: {}, label: { 72 | // Text(verbatim: "confirmation") 73 | // }) 74 | // }) 75 | 76 | // ToolbarItemGroup(placement: .cancellationAction, content: { 77 | // Button(action: {}, label: { 78 | // Text(verbatim: "cancel") 79 | // }) 80 | // }) 81 | 82 | // ToolbarItemGroup(placement: .automatic, content: { 83 | // Button(action: {}, label: { 84 | // Text(verbatim: "automatic") 85 | // }) 86 | // }) 87 | 88 | ToolbarItemGroup(placement: .automatic, content: { 89 | Picker(selection: .constant(0), content: { 90 | Text("picker_1").tag(0) 91 | Text("picker_2").tag(1) 92 | Text("picker_3").tag(2) 93 | }, label: { }) 94 | }) 95 | 96 | ToolbarItemGroup(placement: .automatic, content: { 97 | Picker(selection: .constant(1), content: { 98 | Text("picker").tag(0) 99 | Text("inline").tag(1) 100 | }, label: { }) 101 | .pickerStyle(InlinePickerStyle()) // same as: SegmentedPickerStyle() 102 | }) 103 | 104 | ToolbarItemGroup(placement: .automatic, content: { 105 | Menu(content: { 106 | Button(action: {}, label: { Text(verbatim: "menu_item_1") }) 107 | Button(action: {}, label: { Text(verbatim: "menu_item_2") }) 108 | }, label: { 109 | Text(verbatim: "menu") 110 | }) 111 | }) 112 | 113 | } 114 | .frame(width: 920.0, height: 296.0) 115 | 116 | } 117 | 118 | .windowStyle(.automatic) 119 | .windowToolbarStyle(.automatic) 120 | 121 | } 122 | } 123 | 124 | 125 | // .windowStyle 126 | // .automatic 1 127 | // .hiddenTitleBar 2 128 | // .titleBar 3 129 | 130 | // .windowToolbarStyle 131 | // .automatic 1 132 | // .expanded 2 133 | // .unified 3 134 | // .unifiedCompact 4 135 | -------------------------------------------------------------------------------- /previews/macOS11/1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/1-1.png -------------------------------------------------------------------------------- /previews/macOS11/1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/1-2.png -------------------------------------------------------------------------------- /previews/macOS11/1-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/1-3.png -------------------------------------------------------------------------------- /previews/macOS11/1-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/1-4.png -------------------------------------------------------------------------------- /previews/macOS11/2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/2-1.png -------------------------------------------------------------------------------- /previews/macOS11/2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/2-2.png -------------------------------------------------------------------------------- /previews/macOS11/2-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/2-3.png -------------------------------------------------------------------------------- /previews/macOS11/2-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/2-4.png -------------------------------------------------------------------------------- /previews/macOS11/3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/3-1.png -------------------------------------------------------------------------------- /previews/macOS11/3-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/3-2.png -------------------------------------------------------------------------------- /previews/macOS11/3-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/3-3.png -------------------------------------------------------------------------------- /previews/macOS11/3-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS11/3-4.png -------------------------------------------------------------------------------- /previews/macOS12/1-1-automatic-automatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/1-1-automatic-automatic.png -------------------------------------------------------------------------------- /previews/macOS12/1-2-automatic-expanded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/1-2-automatic-expanded.png -------------------------------------------------------------------------------- /previews/macOS12/1-3-automatic-unified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/1-3-automatic-unified.png -------------------------------------------------------------------------------- /previews/macOS12/1-4-automatic-unifiedCompact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/1-4-automatic-unifiedCompact.png -------------------------------------------------------------------------------- /previews/macOS12/2-1-hiddenTitleBar-automatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/2-1-hiddenTitleBar-automatic.png -------------------------------------------------------------------------------- /previews/macOS12/2-2-hiddenTitleBar-expanded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/2-2-hiddenTitleBar-expanded.png -------------------------------------------------------------------------------- /previews/macOS12/2-3-hiddenTitleBar-unified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/2-3-hiddenTitleBar-unified.png -------------------------------------------------------------------------------- /previews/macOS12/2-4-hiddenTitleBar-unifiedCompact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/2-4-hiddenTitleBar-unifiedCompact.png -------------------------------------------------------------------------------- /previews/macOS12/3-1-titleBar-automatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/3-1-titleBar-automatic.png -------------------------------------------------------------------------------- /previews/macOS12/3-2-titleBar-expanded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/3-2-titleBar-expanded.png -------------------------------------------------------------------------------- /previews/macOS12/3-3-titleBar-unified.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/3-3-titleBar-unified.png -------------------------------------------------------------------------------- /previews/macOS12/3-4-titleBar-unifiedCompact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinlexow/SwiftUIWindowStyles/14873dcb65941c72b253ccf7205625264930aed5/previews/macOS12/3-4-titleBar-unifiedCompact.png --------------------------------------------------------------------------------