Bind the two directions to each other. Tapping a segment animates the content panel to that index; dragging the content panel, in turn, reads its progress (an integer index plus a fractional part) to compute the position of the indicator above — the pill or underline. The indicator needs to keep tracking the finger in real time, before release, for the control and the content to feel like the same thing.
Easy to confuse with a tab bar, but the roles differ. A tab bar moves between separate top-level sections and usually doesn't support swiping. Segmented tabs live inside one screen, switching between related sub-content — posts, replies, likes — so swiping between them is a natural default.
The indicator's position should be computed as a continuous value, `segmentWidth * (index + dragFraction)`, not just snapped at integer indices — skip the in-between and the indicator sits frozen during the drag, then suddenly jumps the moment you let go.
When to use
Use it to switch between related sub-content within one screen — posts, replies, likes. For top-level navigation spanning the whole app, use a tab bar instead.