Conventional optical components such as lenses, waveplates and holograms rely on light propagation over distances much larger than the wavelength to shape wavefronts. In this way substantial changes of the amplitude, phase or polarization of light waves are gradually accumulated along the optical path. This Review focuses on recent developments on flat, ultrathin optical components dubbed 'metasurfaces' that produce abrupt changes over the scale of the free-space wavelength in the phase, amplitude and/or polarization of a light beam. Metasurfaces are generally created by assembling arrays of miniature, anisotropic light scatterers (that is, resonators such as optical antennas). The spacing between antennas and their dimensions are much smaller than the wavelength. As a result the metasurfaces, on account of Huygens principle, are able to mould optical wavefronts into arbitrary shapes with subwavelength resolution by introducing spatial variations in the optical response of the light scatterers. Such gradient metasurfaces go beyond the well-established technology of frequency selective surfaces made of periodic structures and are extending to new spectral regions the functionalities of conventional microwave and millimetre-wave transmit-arrays and reflect-arrays. Metasurfaces can also be created by using ultrathin films of materials with large optical losses. By using the controllable abrupt phase shifts associated with reflection or transmission of light waves at the interface between lossy materials, such metasurfaces operate like optically thin cavities that strongly modify the light spectrum. Technology opportunities in various spectral regions and their potential advantages in replacing existing optical components are discussed.