Swiftpack.co - dkk/WrappingHStack as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by dkk.
dkk/WrappingHStack 2.2.1
A SwiftUI HStack with the ability to wrap contained elements
⭐️ 127
🕓 2 weeks ago
iOS macOS
.package(url: "https://github.com/dkk/WrappingHStack.git", from: "2.2.1")


WrappingHStack is a UI Element that works in a very similar way to HStack, but automatically positions overflowing elements on next lines.



WrappingHStack {
    Text("can handle different element types")
    Image(systemName: "scribble")
        .frame(width: 200, height: 20)
    Text("and loop")
    WrappingHStack(1...20, id:\.self) {
        Text("Item: \($0)")
    }.frame(minWidth: 250)


Requirements iOS 13+

Swift Package Manager

  1. In Xcode, open your project and navigate to File → Swift Packages → Add Package Dependency.
  2. Paste the repository URL (https://github.com/dkk/WrappingHStack) and click Next.
  3. For Rules, select version.
  4. Click Finish.

Swift Package

.package(url: "https://github.com/dkk/WrappingHStack", .upToNextMajor(from: "2.0.0"))


Import the WrappingHStack package to your view:

import WrappingHStack

use it like you would use HStack for single elements:

WrappingHStack {
    /* some views */
    NewLine() // Optional: Use NewLine to force the next element to be placed in a next line
    /* some more views */

or like a ForEach to loop over items:

WrappingHStack(1...30, id:\.self) {
    Text("Item: \($0)")


You can contribute to this project by helping me solve any reported issues or feature requests and creating a pull request.


If you just want to say thanks, you could buy me a coffee ☕️.


WrappingHStack is released under the MIT License.


Stars: 127
Last commit: 5 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 weeks ago

Fixes "Bound preference CGFloatPreferenceKey tried to update multiple times per frame." when scrolling trough multiple WrappingHStack on a scrollview

Thanks to @lucianohandal

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics