title: SwiftUI: Is there a way to put a button inside of a button?
body: <p>I am trying to insert a button inside of another button using SwiftUI. However, if I press that button, it also animates the outer button being pressed, even though it doesn't run the action closure. Is there a way to prevent this, perhaps using a custom ButtonStyle?</p>
  <p>This is what it looks like:</p>
  <p><a href="https://i.stack.imgur.com/BYplB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BYplB.png" alt="Button" /></a></p>
  <p>This is what it looks like when the inner button is pressed:</p>
  <p><a href="https://i.stack.imgur.com/UVUFy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/UVUFy.png" alt="Pressed Button" /></a></p>
  <p>And here is my code:</p>
  <pre class="lang-swift prettyprint-override"><code>var body: some View {
      Button(action: {
          print(&quot;outer button pressed&quot;)
      }) {
          HStack {
              Text(&quot;Button&quot;)
              Spacer()
              Button(action: {
                  print(&quot;inner button pressed&quot;)
              }) {
                  Circle()
                      .foregroundColor(Color.accentColor.opacity(0.2))
                      .frame(width: 28.0, height: 28.0)
                      .overlay(Image(systemName: &quot;ellipsis&quot;))
              }
          }
          .padding()
          .accentColor(.white)
          .background(Color.accentColor)
          .clipShape(RoundedRectangle(cornerRadius: 14.0, style: .continuous))
      }
      .frame(maxWidth: 200.0)
      .padding()
  }
  </code></pre>