A 21-pole superconducting wiggler magnet was designed for medical imaging beamline at Shanghai Synchrotron Radiation Facility (SSRF). The superconducting magnet consists of 21 pairs of NbTi racetrack coils with a period length of 140 mm, and can produce a central peak field of 4.05 T at a pole gap of 22 mm. The critical energy is 33 keV for 3.5 GeV storage ring and the energy of synchrotron photons from wiggler can cover a range from 20 keV to 120 keV for imaging method of K-edge subtraction, diffraction enhanced imaging, phase contrast, computed tomography and microbeam radiation therapy. This paper focuses on the magnetic field design.