Leading alignment in HFlow with only one item #27
Answered
by
tevelee
asalinasfetch
asked this question in
Q&A
|
First, thanks for making this library! I appreciate the effort. I'm trying to create an HFlow that is leading aligned, but I'm having trouble getting that result I want. It seems to default to center aligning the cells when there's only one row. However, when the HFlow has multiple lines the HFlow properly renders the cells as leading aligned. Does anyone have any guidance here? Screen shots and code below. |
Answered by
tevelee
Feb 23, 2025
Replies: 1 comment 1 reply
|
Hi @asalinasfetch, thanks for opening the discussion! I think the best way to align dynamically sized views in SwiftUI is to use the frame modifier. This will make sure to left-align the content if it's shorter than the container view. HFlow {
ForEach(...)
}
.frame(maxWidth: .infinity, alignment: .leading)There was a similar question in #5, hope this helps. |
1 reply
Answer selected by
asalinasfetch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Hi @asalinasfetch, thanks for opening the discussion! I think the best way to align dynamically sized views in SwiftUI is to use the frame modifier. This will make sure to left-align the content if it's shorter than the container view.
There was a similar question in #5, hope this helps.