Neat Software
Neat Software

Follow

Neat Software

Follow

SwiftUI Vertical Divider

Neat Software's photo
Neat Software
ยทJan 10, 2023
struct VerticalDividerExample: View {
    var body: some View {
        HStack(spacing: 20) {
           Text("Left")
           Divider().frame(width: 1)
           Text("Right")
        }
        .padding()
        .frame(width: 200, height: 75)
    }
}

Using the standard Divider view and setting its width to 1 will create a vertical divider.

Setting its width to anything greater than 1 will also produce the vertical effect but it will not render greater than one pixel wide and instead just add padding on each side.

We use vertical dividers in the stats view in our time tracking app Tim: