MergeableView is a SwiftUI package for building Liquid Glass views that can be merged by dragging one item toward another.
The package provides a small set of primitives:
MergeableContainercreates a shared glass effect and merge coordinate space..mergeableItem(id:)marks each view as a merge target..onMergeonForEachreports the source and destination indices when a merge gesture completes.
- iOS 26.0+ or macOS 26.0+
- Swift 6
- Swift Package Manager
Add this package to your Swift Package Manager dependencies:
dependencies:[.package(url:"https://github.com/noppefoxwolf/MergeableView.git", branch:"main")]Then add MergeableView to your target dependencies:
.product(name:"MergeableView",package:"MergeableView")Import the package and wrap mergeable views in MergeableContainer.
import MergeableView
import SwiftUI
structContentView:View{@Stateprivatevartokens=[Token(text:"Liquid"),Token(text:"Glass"),Token(text:"Effect")]varbody:someView{MergeableContainer{VStack(alignment:.leading){ForEach(tokens){ token inText(token.text).bold().padding().glassEffect(.regular.interactive()).mergeableItem(id: token.id)}.onMerge{ sourceIndex, destinationIndex inmerge(sourceIndex, with: destinationIndex)}}}}privatefunc merge(_ sourceIndex:Int, with destinationIndex:Int){guard
sourceIndex != destinationIndex,
tokens.indices.contains(sourceIndex),
tokens.indices.contains(destinationIndex)else{return}letorderedIndices=[sourceIndex, destinationIndex].sorted()letsource=tokens[orderedIndices[0]]letdestination=tokens[orderedIndices[1]]letmergedToken=Token(text:"\(source.text)\(destination.text)")
tokens.remove(at:orderedIndices[1])
tokens.remove(at:orderedIndices[0])
tokens.insert(mergedToken, at:orderedIndices[0])}}structToken:Identifiable,Hashable{letid=UUID()vartext:String}Drag from one mergeable item toward another item to trigger .onMerge. The callback receives the source index and destination index from the ForEach data.
An example app is included in Example.swiftpm.
Open Example.swiftpm in Xcode and run the Example app on an iOS 26 simulator or device.
MergeableView is available under the MIT License. See LICENSE for details.
