FREE TRIAL: Accelerate your app development career with Hacking with Swift+! >>

What am I doing wrong (Terrible google search skills and a general lack of experience)

Forums > SwiftUI

Removed text of oroginal post for clarity.

Is it possible to dynamically add more UI elements to a VStack? All of the examples I find through google searching is about texts and lists. I am looking to basically add a vstack to a vstack when the user presses a button.



i think the answer to your question is no, but consider an alternative: perhaps a conditional inclusion of the inner VStack within the outer VStack, controlled by a @State private var isShown: Bool variable that is set to true when the user presses a button.

something like this

VStack {
  // stuff you always want to be seen
  if isShown {
    VStack {
    // stuff to be seen when the user taps a button

hope that helps,



Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for iOS devs who want to become complete senior developers — from October 18th to 24th. Learn how to apply iOS app architecture patterns through a series of lectures and practical coding sessions.

Learn more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.