This paper presents the design of a decentralized cooperative control law, based on a leader-follower approach. This control law generates formation trajectories that should follow each mobile robot to establish and maintain a specific geometry formation while the robots formation moves along a predefined trajectory. By taking advantage of the continuous and discrete dynamics of the leader-following approach, we model the formation control as a switching control. This allows any robot to be part of the formation as leader or follower any time. The control law is validated through simulation.