.border(), .borderLeft() ...

import SwiftUI

// ๐ŸŒ€View + .border(width, color, dash)
extension View {
    
    /// # Border Line
    /// draws solid line if `dash` is omitted.
    /// ## โญ๏ธ Examples:
    /// - `view.border() == view.border(1)`
    /// - `view.border(2, .red)`
    /// - `view.border(dash: [3])`
    /// - `view.border(1, .pink, dash: [5])`
    @ViewBuilder public func border(
        _ width: CGFloat    = 1, 
        _ color: Color      = .blue, 
        dash   : [CGFloat]? = nil
    ) -> some View {
        if dash != nil {
            self.overlay(
                Rectangle()
                    .stroke(color, style: .init(lineWidth: width, dash: dash!))
            )
        } else {
            self.border(color, width: width)
        }
    }
    
}

Last updated