  Magnetic switchbacks are rapid high amplitude reversals of the radial
magnetic field in the solar wind that do not involve a heliospheric current
sheet crossing. First seen sporadically in the seventies in Mariner and Helios
data, switchbacks were later observed by the Ulysses spacecraft beyond 1 au and
have been recently identified as a typical component of solar wind fluctuations
in the inner heliosphere by the Parker Solar Probe spacecraft. Here we provide
a simple yet predictive theory for the formation of these magnetic reversals:
the switchbacks are produced by the shear of circularly polarized Alfv\'en
waves by a transversely varying radial wave propagation velocity. We provide an
analytic expression for the magnetic field variation, establish the necessary
and sufficient conditions and show that the mechanism works in a realistic
solar wind scenario.
