Layout multiple SwiftUI previews horizontally (or in grid) instead of vertically? Layout multiple SwiftUI previews horizontally (or in grid) instead of vertically? xcode xcode

Layout multiple SwiftUI previews horizontally (or in grid) instead of vertically?


You can achieve it like this. This way it doesn't show iPhone borders but views render it as how it will look on iPhone 11 Pro screen.

struct SidebarView_Previews: PreviewProvider {    static var previews: some View {        HStack {            //... All your views ...        }.previewLayout(.fixed(width: 375 * 2, height: 812))    }}


Just replace the preview Group by an HStack, this way:

struct SidebarView_Previews: PreviewProvider {    static var previews: some View {        Group {            //... All your views ...        }            }}

to:

struct SidebarView_Previews: PreviewProvider {    static var previews: some View {        HStack(spacing: 20) {            //... All your views ...        }            }}