r/iOSProgramming • u/Brilliant_Water8552 • 41m ago
Question How to recreate the native draggable tab bar indicator without the background?
Hey everyone,
I’m currently developing a Swift app and want to recreate the native iOS tab bar interaction, but with just the text labels and the draggable selection pill, without the surrounding tab bar background.
The ChatGPT iOS app implemented pretty much exactly what I’m looking for in a recent update.
I’ve already tried a bunch of different approaches:
Modifying existing tab bar recreations on GitHub to remove the background
Looking for standalone implementations of the draggable selection pill
Exploring projects that use undocumented APIs
Unfortunately, most of these approaches are either too limited or don’t quite capture the native look and feel, especially when it comes to animations and dragging behavior.
Does anyone have an idea how to achieve this? Ideally using public APIs, but I’d also be interested in understanding how ChatGPT implements it.
I’ve attached a screen recording showing exactly what I’m trying to achieve.
Any help would be greatly appreciated!
•
u/Sea_Wrongdoer_3500 2m ago
dont think theres a public api that gives you just the pill, but you can get pretty close yourself
basic idea: HStack of your items, pill is a capsule behind the selected one with matchedGeometryEffect so it slides on tap. for dragging, add a DragGesture on the whole row, move the pill with the finger (clamp to the row), and on end snap to the nearest item with a spring. thats most of the "native" feel tbh, the spring + snap
on ios 26 you can make the pill glass with .glassEffect(.regular.interactive()) inside a GlassEffectContainer, and give it a glassEffectID so it morphs between positions instead of just sliding. the interactive part gives you that little stretch/press reaction
also quick haptic (sensoryFeedback .selection) every time the pill crosses into a new item, people notice when thats missing
no idea how chatgpt does it internally tho
•
u/ThanhDongNguyen 18m ago
I can't say how ChatGPT does it exactly, but I think you can build it without private APIs. The pill is basically a Capsule that moves between the item frames. I would put the tab items in an HStack, store each item frame with a preference key, and draw one capsule behind them with offset and width following the selected index.
For the drag, put a DragGesture with minimumDistance 0 on the whole row and convert the x position to the nearest index. While dragging, let the capsule follow the finger, and on end snap it to the closest item with a spring animation.
If you only target iOS 26, you can fill the capsule with glassEffect(.regular.interactive()). That should give you the glass look and the press feedback, without a background behind the whole bar. I would get the plain version working first and add the glass after the drag feels right.