A SwiftUI flow layout that automatically inserts a separator between items and hides it when it would end up at the end of a line.
.package(url: "https://github.com/bernndr/InlineFlowSeparatorLayout.git", from: "0.1.0")Alternatively, add the package from Xcode using the project's repository URL.
import SwiftUI
import InlineFlowSeparatorLayout
struct ContentView: View {
let tags = ["Swift", "SwiftUI", "iOS", "Xcode", "Layout", "SPM"]
var body: some View {
HFlowSeparator(spacing: 8) {
Text("•")
.foregroundStyle(.secondary)
} content: {
ForEach(tags, id: \.self) { tag in
Text(tag)
.padding(.horizontal, 12)
.padding(.vertical, 6)
.background(.blue.opacity(0.12))
.clipShape(Capsule())
}
}
.padding()
}
}You can control the horizontal alignment of each row with the alignment parameter.
HFlowSeparator(alignment: .center, spacing: 8) {
Image(systemName: "circle.fill")
.font(.caption2)
.foregroundStyle(.secondary)
} content: {
ForEach(tags, id: \.self) { item in
Text(item)
}
}- iOS 18+
- Swift 6
- Xcode with Swift Package Manager and
Layoutprotocol support
