Potentiometer position sensor works on the principle of the resistance value varying with the movement displacement.
These sensors basically have a potentiometer built in it whose resistance can be altered using a slider, this resistive track is used as a sensing element for measuring the distance, resistance is proportional to physical position, in the end, we can consider the principle as similar to slide rheostat which we learned in middle school.