In SwiftUI, how do I let two glass buttons morph into each other

Asked on 2025-09-12

1 search

To let two glass buttons morph into each other in SwiftUI, you can use the new Liquid Glass effects introduced in the WWDC 2025 sessions. Specifically, you can use the Glass Effect ID modifier to create fluid morphing transitions between glass elements. Here's a brief overview of how you can achieve this:

  1. Declare a Local Namespace: Start by declaring a local namespace in your SwiftUI view.

  2. Associate the Namespace: Associate this namespace with each of the glass effect elements you want to morph together. This includes the buttons and any other elements involved in the transition.

  3. Use the Glass Effect ID Modifier: Apply the Glass Effect ID modifier to your elements. This will allow them to morph fluidly as they transition between states.

For more detailed guidance, you can refer to the session Build a SwiftUI app with the new design (20:40) where these concepts are discussed in the context of creating fluid morphing effects with the Liquid Glass material.