Reading time: 1 min
Ocassionally you wish to make a View fit entire width of its parent. You can do so by setting both minWidth and maxWidth:
Text("Some text")
  .frame(minWidth: 0, maxWidth: .infinity)
For a Text specifically, this is even more useful if you wish to have it, say, leading-aligned in a center-aligned VStack:
VStack { // default alignment is .center
Text("Some text")
  .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
}
            
    
    Search our recipes
Related Posts
- 100 Insert Image into SwiftUI Text
 - 100 SwiftUI Touch Enter and Exit Gesture
 - 100 Minimum, Maximum and Average on SwiftUI Bar Chart
 - 100 Styling SwiftUI Chart with Charts Framework
 - 100 Chart Scan Line / Lollipop in SwiftUI with Charts Framework
 
Check out the companion apps!
Our free companion app and XCode Extension brings 100+ SwiftUI recipes right at your fingertips! Get a preview of it in the Online Companion.
Have a recipe for us?
Get in touch and let's grow the cookbook together!